svn commit: samba r23869 - in branches: SAMBA_3_2/source/libads SAMBA_3_2_0/source/libads

gd at samba.org gd at samba.org
Fri Jul 13 23:26:56 GMT 2007


Author: gd
Date: 2007-07-13 23:26:55 +0000 (Fri, 13 Jul 2007)
New Revision: 23869

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=23869

Log:
Protect against partial security descriptors.

Guenther

Modified:
   branches/SAMBA_3_2/source/libads/disp_sec.c
   branches/SAMBA_3_2_0/source/libads/disp_sec.c


Changeset:
Modified: branches/SAMBA_3_2/source/libads/disp_sec.c
===================================================================
--- branches/SAMBA_3_2/source/libads/disp_sec.c	2007-07-13 22:05:05 UTC (rev 23868)
+++ branches/SAMBA_3_2/source/libads/disp_sec.c	2007-07-13 23:26:55 UTC (rev 23869)
@@ -88,6 +88,10 @@
 {
 	const char *ret = NULL;
 
+	if (!ads || !mem_ctx) {
+		return NULL;
+	}
+
 	ret = ads_get_attrname_by_guid(ads, ads->config.schema_path, 
 				       mem_ctx, guid);
 	if (ret) {
@@ -188,13 +192,17 @@
 	int i;
 	char *tmp_path = NULL;
 
-	if (!ads->config.schema_path) {
+	if (!sd) {
+		return;
+	}
+
+	if (ads && !ads->config.schema_path) {
 		if (ADS_ERR_OK(ads_schema_path(ads, mem_ctx, &tmp_path))) {
 			ads->config.schema_path = SMB_STRDUP(tmp_path);
 		}
 	}
 
-	if (!ads->config.config_path) {
+	if (ads && !ads->config.config_path) {
 		if (ADS_ERR_OK(ads_config_path(ads, mem_ctx, &tmp_path))) {
 			ads->config.config_path = SMB_STRDUP(tmp_path);
 		}
@@ -203,16 +211,25 @@
 	printf("-------------- Security Descriptor (revision: %d, type: 0x%02x)\n", 
                sd->revision,
                sd->type);
-	printf("owner SID: %s\n", sid_string_static(sd->owner_sid));
-	printf("group SID: %s\n", sid_string_static(sd->group_sid));
 
+	printf("owner SID: %s\n", sd->owner_sid ? 
+		sid_string_static(sd->owner_sid) : "(null)");
+	printf("group SID: %s\n", sd->group_sid ?
+		sid_string_static(sd->group_sid) : "(null)");
+
 	ads_disp_acl(sd->sacl, "system");
-	for (i = 0; i < sd->sacl->num_aces; i ++)
-		ads_disp_ace(ads, mem_ctx, &sd->sacl->aces[i]);
+	if (sd->sacl) {
+		for (i = 0; i < sd->sacl->num_aces; i ++) {
+			ads_disp_ace(ads, mem_ctx, &sd->sacl->aces[i]);
+		}
+	}
 	
 	ads_disp_acl(sd->dacl, "user");
-	for (i = 0; i < sd->dacl->num_aces; i ++)
-		ads_disp_ace(ads, mem_ctx, &sd->dacl->aces[i]);
+	if (sd->dacl) {
+		for (i = 0; i < sd->dacl->num_aces; i ++) {
+			ads_disp_ace(ads, mem_ctx, &sd->dacl->aces[i]);
+		}
+	}
 
 	printf("-------------- End Of Security Descriptor\n");
 }

Modified: branches/SAMBA_3_2_0/source/libads/disp_sec.c
===================================================================
--- branches/SAMBA_3_2_0/source/libads/disp_sec.c	2007-07-13 22:05:05 UTC (rev 23868)
+++ branches/SAMBA_3_2_0/source/libads/disp_sec.c	2007-07-13 23:26:55 UTC (rev 23869)
@@ -88,6 +88,10 @@
 {
 	const char *ret = NULL;
 
+	if (!ads || !mem_ctx) {
+		return NULL;
+	}
+
 	ret = ads_get_attrname_by_guid(ads, ads->config.schema_path, 
 				       mem_ctx, guid);
 	if (ret) {
@@ -188,13 +192,17 @@
 	int i;
 	char *tmp_path = NULL;
 
-	if (!ads->config.schema_path) {
+	if (!sd) {
+		return;
+	}
+
+	if (ads && !ads->config.schema_path) {
 		if (ADS_ERR_OK(ads_schema_path(ads, mem_ctx, &tmp_path))) {
 			ads->config.schema_path = SMB_STRDUP(tmp_path);
 		}
 	}
 
-	if (!ads->config.config_path) {
+	if (ads && !ads->config.config_path) {
 		if (ADS_ERR_OK(ads_config_path(ads, mem_ctx, &tmp_path))) {
 			ads->config.config_path = SMB_STRDUP(tmp_path);
 		}
@@ -203,16 +211,25 @@
 	printf("-------------- Security Descriptor (revision: %d, type: 0x%02x)\n", 
                sd->revision,
                sd->type);
-	printf("owner SID: %s\n", sid_string_static(sd->owner_sid));
-	printf("group SID: %s\n", sid_string_static(sd->group_sid));
 
+	printf("owner SID: %s\n", sd->owner_sid ? 
+		sid_string_static(sd->owner_sid) : "(null)");
+	printf("group SID: %s\n", sd->group_sid ?
+		sid_string_static(sd->group_sid) : "(null)");
+
 	ads_disp_acl(sd->sacl, "system");
-	for (i = 0; i < sd->sacl->num_aces; i ++)
-		ads_disp_ace(ads, mem_ctx, &sd->sacl->aces[i]);
+	if (sd->sacl) {
+		for (i = 0; i < sd->sacl->num_aces; i ++) {
+			ads_disp_ace(ads, mem_ctx, &sd->sacl->aces[i]);
+		}
+	}
 	
 	ads_disp_acl(sd->dacl, "user");
-	for (i = 0; i < sd->dacl->num_aces; i ++)
-		ads_disp_ace(ads, mem_ctx, &sd->dacl->aces[i]);
+	if (sd->dacl) {
+		for (i = 0; i < sd->dacl->num_aces; i ++) {
+			ads_disp_ace(ads, mem_ctx, &sd->dacl->aces[i]);
+		}
+	}
 
 	printf("-------------- End Of Security Descriptor\n");
 }



More information about the samba-cvs mailing list