Skip to contentSkip to conversation

policycoreutils: prevent null deref

PATCH New Serge E. Hallyn 1 participant 1 message Jun 9, 2006 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 policycoreutils: prevent null deref

If the allocation of vallist fails, we jump to the error path where we immediately try to free vallist[i]. Make sure that doesn't happen.

I'd like to happily point out that this seems to address the last valid-seeming bug found by our internal code checker :)

thanks,
-serge

setsebool/setsebool.c renamed from setsebool/setsebool.c.orig +5 -3
@@ -252,9 +252,11 @@ int setbool(char **list, size_t start, s
 	fprintf(stderr, "setsebool: out of memory");
 		
 	err:
-	for (i=0; i < boolcnt; i++) 
-		free(vallist[i].name);
-	free(vallist);
+	if (vallist) {
+		for (i=0; i < boolcnt; i++) 
+			free(vallist[i].name);
+		free(vallist);
+	}
 	return -1;
 }
 

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.