summaryrefslogtreecommitdiff
path: root/librpc
diff options
context:
space:
mode:
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>2018-03-22 17:12:49 +1300
committerAndrew Bartlett <abartlet@samba.org>2018-05-31 01:57:16 +0200
commitcd2365175f5e9d5b5e2725fecf07b3862d3923df (patch)
tree169097c2df13396dfd06ba9b11d7bbaa16e97866 /librpc
parentf9308648e9a675205ac57302aa6393a37723cddf (diff)
downloadsamba-cd2365175f5e9d5b5e2725fecf07b3862d3923df.tar.gz
ndr_misc: read syntax_id using strict util_str_hex functions
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'librpc')
-rw-r--r--librpc/ndr/ndr_misc.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/librpc/ndr/ndr_misc.c b/librpc/ndr/ndr_misc.c
index fa643c84949..155ab8f21b8 100644
--- a/librpc/ndr/ndr_misc.c
+++ b/librpc/ndr/ndr_misc.c
@@ -23,6 +23,8 @@
#include "includes.h"
#include "system/network.h"
#include "librpc/ndr/libndr.h"
+#include "libcli/util/ntstatus.h"
+#include "lib/util/util_str_hex.h"
_PUBLIC_ void ndr_print_GUID(struct ndr_print *ndr, const char *name, const struct GUID *guid)
{
@@ -52,21 +54,32 @@ _PUBLIC_ char *ndr_syntax_id_to_string(TALLOC_CTX *mem_ctx, const struct ndr_syn
_PUBLIC_ bool ndr_syntax_id_from_string(const char *s, struct ndr_syntax_id *id)
{
- int ret;
size_t i;
uint32_t time_low;
uint32_t time_mid, time_hi_and_version;
uint32_t clock_seq[2];
uint32_t node[6];
- uint32_t if_version;
+ uint64_t if_version;
+ NTSTATUS status;
- ret = sscanf(s,
- "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x/0x%08x",
- &time_low, &time_mid, &time_hi_and_version,
- &clock_seq[0], &clock_seq[1],
- &node[0], &node[1], &node[2], &node[3], &node[4], &node[5],
- &if_version);
- if (ret != 12) {
+ status = parse_guid_string(s,
+ &time_low,
+ &time_mid,
+ &time_hi_and_version,
+ clock_seq,
+ node);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
+
+ if (strncmp(s + 36, "/0x", 3) != 0) {
+ return false;
+ }
+
+ status = read_hex_bytes(s + 39, 8, &if_version);
+
+ if (!NT_STATUS_IS_OK(status)) {
return false;
}
@@ -78,7 +91,7 @@ _PUBLIC_ bool ndr_syntax_id_from_string(const char *s, struct ndr_syntax_id *id)
for (i=0; i<6; i++) {
id->uuid.node[i] = node[i];
}
- id->if_version = if_version;
+ id->if_version = (uint32_t)if_version;
return true;
}