diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2008-12-20 20:33:02 +0100 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2008-12-20 20:33:02 +0100 |
commit | 9b16a5ac163025c49b40b7f32f6145da46cd75b8 (patch) | |
tree | e468c68a9f15417a19cbb451a1c074dcda6b3f34 /librpc/ndr/uuid.c | |
parent | 28f80dbb7cc7daeb6d285dd26d3ef32a42af93ca (diff) | |
parent | f210fbe68b07cadd8ca3e358b1579a9c602cc7f8 (diff) | |
download | samba-9b16a5ac163025c49b40b7f32f6145da46cd75b8.tar.gz samba-9b16a5ac163025c49b40b7f32f6145da46cd75b8.tar.bz2 samba-9b16a5ac163025c49b40b7f32f6145da46cd75b8.zip |
Merge branch 'master' of ssh://git.samba.org/data/git/samba into tevent-standalone
Diffstat (limited to 'librpc/ndr/uuid.c')
-rw-r--r-- | librpc/ndr/uuid.c | 49 |
1 files changed, 35 insertions, 14 deletions
diff --git a/librpc/ndr/uuid.c b/librpc/ndr/uuid.c index aa24ac4494..2b47246806 100644 --- a/librpc/ndr/uuid.c +++ b/librpc/ndr/uuid.c @@ -36,6 +36,7 @@ _PUBLIC_ NTSTATUS GUID_from_data_blob(const DATA_BLOB *s, struct GUID *guid) uint32_t clock_seq[2]; uint32_t node[6]; uint8_t buf16[16]; + DATA_BLOB blob16 = data_blob_const(buf16, sizeof(buf16)); int i; @@ -43,20 +44,40 @@ _PUBLIC_ NTSTATUS GUID_from_data_blob(const DATA_BLOB *s, struct GUID *guid) return NT_STATUS_INVALID_PARAMETER; } - if (s->length == 36 && - 11 == sscanf((const char *)s->data, - "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", - &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])) { - status = NT_STATUS_OK; - } else if (s->length == 38 - && 11 == sscanf((const char *)s->data, - "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", - &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])) { - status = NT_STATUS_OK; + if (s->length == 36) { + TALLOC_CTX *mem_ctx; + const char *string; + + mem_ctx = talloc_new(NULL); + NT_STATUS_HAVE_NO_MEMORY(mem_ctx); + string = talloc_strndup(mem_ctx, (const char *)s->data, s->length); + NT_STATUS_HAVE_NO_MEMORY(string); + if (11 == sscanf(string, + "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + &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])) { + status = NT_STATUS_OK; + } + talloc_free(mem_ctx); + + } else if (s->length == 38) { + TALLOC_CTX *mem_ctx; + const char *string; + + mem_ctx = talloc_new(NULL); + NT_STATUS_HAVE_NO_MEMORY(mem_ctx); + string = talloc_strndup(mem_ctx, (const char *)s->data, s->length); + NT_STATUS_HAVE_NO_MEMORY(string); + if (11 == sscanf((const char *)s->data, + "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", + &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])) { + status = NT_STATUS_OK; + } + talloc_free(mem_ctx); + } else if (s->length == 32) { size_t rlen = strhex_to_str((char *)blob16.data, blob16.length, (const char *)s->data, s->length); |