diff options
-rw-r--r-- | source/lib/display_sec.c | 4 | ||||
-rw-r--r-- | source/lib/util_uuid.c | 44 | ||||
-rw-r--r-- | source/libads/disp_sec.c | 4 | ||||
-rw-r--r-- | source/libads/ldap.c | 11 | ||||
-rw-r--r-- | source/libsmb/dsgetdcname.c | 2 | ||||
-rw-r--r-- | source/printing/nt_printing.c | 6 | ||||
-rw-r--r-- | source/rpc_server/srv_spoolss_nt.c | 3 | ||||
-rw-r--r-- | source/rpcclient/cmd_lsarpc.c | 3 | ||||
-rw-r--r-- | source/utils/net_ads.c | 7 |
9 files changed, 38 insertions, 46 deletions
diff --git a/source/lib/display_sec.c b/source/lib/display_sec.c index 8e92c84f3cd..caa13a6a5ee 100644 --- a/source/lib/display_sec.c +++ b/source/lib/display_sec.c @@ -97,12 +97,12 @@ static void disp_sec_ace_object(struct security_ace_object *object) { if (object->flags & SEC_ACE_OBJECT_PRESENT) { printf("Object type: SEC_ACE_OBJECT_PRESENT\n"); - printf("Object GUID: %s\n", smb_uuid_string_static( + printf("Object GUID: %s\n", smb_uuid_string(talloc_tos(), object->type.type)); } if (object->flags & SEC_ACE_OBJECT_INHERITED_PRESENT) { printf("Object type: SEC_ACE_OBJECT_INHERITED_PRESENT\n"); - printf("Object GUID: %s\n", smb_uuid_string_static( + printf("Object GUID: %s\n", smb_uuid_string(talloc_tos(), object->inherited_type.inherited_type)); } } diff --git a/source/lib/util_uuid.c b/source/lib/util_uuid.c index 606bfd2147c..36c04e9b849 100644 --- a/source/lib/util_uuid.c +++ b/source/lib/util_uuid.c @@ -44,14 +44,6 @@ void smb_uuid_unpack(const UUID_FLAT in, struct GUID *uu) memcpy(uu->node, in.info+10, 6); } -struct GUID smb_uuid_unpack_static(const UUID_FLAT in) -{ - static struct GUID uu; - - smb_uuid_unpack(in, &uu); - return uu; -} - void smb_uuid_generate_random(struct GUID *uu) { UUID_FLAT tmp; @@ -63,30 +55,20 @@ void smb_uuid_generate_random(struct GUID *uu) uu->time_hi_and_version = (uu->time_hi_and_version & 0x0FFF) | 0x4000; } -char *smb_uuid_to_string(const struct GUID uu) -{ - char *out; - - asprintf(&out, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", - uu.time_low, uu.time_mid, uu.time_hi_and_version, - uu.clock_seq[0], uu.clock_seq[1], - uu.node[0], uu.node[1], uu.node[2], - uu.node[3], uu.node[4], uu.node[5]); - - return out; -} - -const char *smb_uuid_string_static(const struct GUID uu) +const char *smb_uuid_string(TALLOC_CTX *mem_ctx, const struct GUID uu) { - static char out[37]; - - slprintf(out, sizeof(out), - "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", - uu.time_low, uu.time_mid, uu.time_hi_and_version, - uu.clock_seq[0], uu.clock_seq[1], - uu.node[0], uu.node[1], uu.node[2], - uu.node[3], uu.node[4], uu.node[5]); - return out; + char *result; + + result = talloc_asprintf( + mem_ctx, + "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + uu.time_low, uu.time_mid, uu.time_hi_and_version, + uu.clock_seq[0], uu.clock_seq[1], + uu.node[0], uu.node[1], uu.node[2], + uu.node[3], uu.node[4], uu.node[5]); + + SMB_ASSERT(result != NULL); + return result; } bool smb_string_to_uuid(const char *in, struct GUID* uu) diff --git a/source/libads/disp_sec.c b/source/libads/disp_sec.c index e85809635f1..e211ef69e44 100644 --- a/source/libads/disp_sec.c +++ b/source/libads/disp_sec.c @@ -114,14 +114,14 @@ static void ads_disp_sec_ace_object(ADS_STRUCT *ads, { if (object->flags & SEC_ACE_OBJECT_PRESENT) { printf("Object type: SEC_ACE_OBJECT_PRESENT\n"); - printf("Object GUID: %s (%s)\n", smb_uuid_string_static( + printf("Object GUID: %s (%s)\n", smb_uuid_string(mem_ctx, object->type.type), ads_interprete_guid_from_object(ads, mem_ctx, &object->type.type)); } if (object->flags & SEC_ACE_OBJECT_INHERITED_PRESENT) { printf("Object type: SEC_ACE_OBJECT_INHERITED_PRESENT\n"); - printf("Object GUID: %s (%s)\n", smb_uuid_string_static( + printf("Object GUID: %s (%s)\n", smb_uuid_string(mem_ctx, object->inherited_type.inherited_type), ads_interprete_guid_from_object(ads, mem_ctx, &object->inherited_type.inherited_type)); diff --git a/source/libads/ldap.c b/source/libads/ldap.c index 01f6b00c025..533aa3026f5 100644 --- a/source/libads/ldap.c +++ b/source/libads/ldap.c @@ -1828,11 +1828,14 @@ static void dump_binary(ADS_STRUCT *ads, const char *field, struct berval **valu static void dump_guid(ADS_STRUCT *ads, const char *field, struct berval **values) { int i; - UUID_FLAT guid; for (i=0; values[i]; i++) { + + UUID_FLAT guid; + struct GUID tmp; + memcpy(guid.info, values[i]->bv_val, sizeof(guid.info)); - printf("%s: %s\n", field, - smb_uuid_string_static(smb_uuid_unpack_static(guid))); + smb_uuid_unpack(guid, &tmp); + printf("%s: %s\n", field, smb_uuid_string(talloc_tos(), tmp)); } } @@ -3429,7 +3432,7 @@ const char *ads_get_extended_right_name_by_guid(ADS_STRUCT *ads, } expr = talloc_asprintf(mem_ctx, "(rightsGuid=%s)", - smb_uuid_string_static(*rights_guid)); + smb_uuid_string(mem_ctx, *rights_guid)); if (!expr) { goto done; } diff --git a/source/libsmb/dsgetdcname.c b/source/libsmb/dsgetdcname.c index f6c32730844..b0870e249e8 100644 --- a/source/libsmb/dsgetdcname.c +++ b/source/libsmb/dsgetdcname.c @@ -800,7 +800,7 @@ static NTSTATUS process_dc_dns(TALLOC_CTX *mem_ctx, dc_address_type = ADS_NETBIOS_ADDRESS; } NT_STATUS_HAVE_NO_MEMORY(dc_address); - dc_guid = smb_uuid_unpack_static(r.guid); + smb_uuid_unpack(r.guid, &dc_guid); if (r.forest) { dc_flags |= ADS_DNS_FOREST; diff --git a/source/printing/nt_printing.c b/source/printing/nt_printing.c index bbe312ca277..c55f9f1f915 100644 --- a/source/printing/nt_printing.c +++ b/source/printing/nt_printing.c @@ -3208,7 +3208,8 @@ static void store_printer_guid(NT_PRINTER_INFO_LEVEL_2 *info2, Vista to whine */ ZERO_STRUCT( unistr_guid ); - init_unistr2( &unistr_guid, smb_uuid_string_static(guid), + + init_unistr2( &unistr_guid, smb_uuid_string(talloc_tos(), guid), UNI_STR_TERMINATE ); regval_ctr_addvalue(ctr, "objectGUID", REG_SZ, @@ -3821,7 +3822,8 @@ static int unpack_values(NT_PRINTER_DATA *printer_data, const uint8 *buf, int bu memcpy( &guid, data_p, sizeof(struct GUID) ); - init_unistr2( &unistr_guid, smb_uuid_string_static(guid), + init_unistr2( &unistr_guid, + smb_uuid_string(talloc_tos(), guid), UNI_STR_TERMINATE ); regval_ctr_addvalue( printer_data->keys[key_index].values, diff --git a/source/rpc_server/srv_spoolss_nt.c b/source/rpc_server/srv_spoolss_nt.c index fe7a12940ee..d49731272fb 100644 --- a/source/rpc_server/srv_spoolss_nt.c +++ b/source/rpc_server/srv_spoolss_nt.c @@ -4376,7 +4376,8 @@ static bool construct_printer_info_7(Printer_entry *print_hnd, PRINTER_INFO_7 *p struct GUID guid; if (is_printer_published(print_hnd, snum, &guid)) { - asprintf(&guid_str, "{%s}", smb_uuid_string_static(guid)); + asprintf(&guid_str, "{%s}", + smb_uuid_string(talloc_tos(), guid)); strupper_m(guid_str); init_unistr(&printer->guid, guid_str); printer->action = SPOOL_DS_PUBLISH; diff --git a/source/rpcclient/cmd_lsarpc.c b/source/rpcclient/cmd_lsarpc.c index 31a8e2bdfd1..fd7b8762ab5 100644 --- a/source/rpcclient/cmd_lsarpc.c +++ b/source/rpcclient/cmd_lsarpc.c @@ -126,7 +126,8 @@ static void display_query_info_12(DOM_QUERY_12 d) d_printf("Domain DNS Name: %s\n", dns_dom_name); d_printf("Domain Forest Name: %s\n", forest_name); d_printf("Domain Sid: %s\n", sid_string_static(&d.dom_sid.sid)); - d_printf("Domain GUID: %s\n", smb_uuid_string_static(d.dom_guid)); + d_printf("Domain GUID: %s\n", smb_uuid_string(talloc_tos(), + d.dom_guid)); } diff --git a/source/utils/net_ads.c b/source/utils/net_ads.c index 81b13ba76ec..ac8f7943549 100644 --- a/source/utils/net_ads.c +++ b/source/utils/net_ads.c @@ -80,6 +80,7 @@ static int net_ads_cldap_netlogon(ADS_STRUCT *ads) { char addr[INET6_ADDRSTRLEN]; struct cldap_netlogon_reply reply; + struct GUID tmp_guid; print_sockaddr(addr, sizeof(addr), &ads->ldap.ss); if ( !ads_cldap_netlogon(addr, ads->server.realm, &reply ) ) { @@ -102,8 +103,10 @@ static int net_ads_cldap_netlogon(ADS_STRUCT *ads) d_printf("0x%x\n", reply.type); break; } - d_printf("GUID: %s\n", - smb_uuid_string_static(smb_uuid_unpack_static(reply.guid))); + + smb_uuid_unpack(reply.guid, &tmp_guid); + d_printf("GUID: %s\n", smb_uuid_string(talloc_tos(), tmp_guid)); + d_printf("Flags:\n" "\tIs a PDC: %s\n" "\tIs a GC of the forest: %s\n" |