svn commit: samba r14765 - in trunk/source/lib: .

jra at samba.org jra at samba.org
Wed Mar 29 22:41:36 GMT 2006


Author: jra
Date: 2006-03-29 22:41:36 +0000 (Wed, 29 Mar 2006)
New Revision: 14765

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

Log:
Fix possible null pointer deref. Coverity #253.
Jeremy.

Modified:
   trunk/source/lib/util_pw.c


Changeset:
Modified: trunk/source/lib/util_pw.c
===================================================================
--- trunk/source/lib/util_pw.c	2006-03-29 22:41:24 UTC (rev 14764)
+++ trunk/source/lib/util_pw.c	2006-03-29 22:41:36 UTC (rev 14765)
@@ -25,6 +25,9 @@
 struct passwd *tcopy_passwd(TALLOC_CTX *mem_ctx, const struct passwd *from) 
 {
 	struct passwd *ret = TALLOC_P(mem_ctx, struct passwd);
+	if (!ret) {
+		return NULL;
+	}
 	ret->pw_name = talloc_strdup(ret, from->pw_name);
 	ret->pw_passwd = talloc_strdup(ret, from->pw_passwd);
 	ret->pw_uid = from->pw_uid;
@@ -99,8 +102,7 @@
 	}
 
 	pwnam_cache[i] = tcopy_passwd(pwnam_cache, temp);
-
-	if (mem_ctx != NULL) {
+	if (pwnam_cache[i]!= NULL && mem_ctx != NULL) {
 		return talloc_reference(mem_ctx, pwnam_cache[i]);
 	}
 



More information about the samba-cvs mailing list