[Fedora-directory-commits] ldapserver/lib/ldaputil certmap.c, 1.5, 1.6 init.c, 1.6, 1.7 ldapauth.c, 1.5, 1.6

Richard Allen Megginson (rmeggins) fedora-directory-commits at redhat.com
Tue Apr 11 02:14:55 UTC 2006


Author: rmeggins

Update of /cvs/dirsec/ldapserver/lib/ldaputil
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv8136/ldapserver/lib/ldaputil

Modified Files:
	certmap.c init.c ldapauth.c 
Log Message:
Bug(s) fixed: 186280
Bug Description: ldapserver: Close potential security vulnerabilities in CGI code
Reviewed by: Nathan, Noriko, and Pete (Thanks!)
Fix Description: Clean up usage of sprintf, strcpy, fgets instead of
gets, fixed buffer usage, etc., mostly in the CGI code and other user
facing code (i.e. setup).  Also, Steve Grubb told me about a GCC trick
to force it to check printf style varargs functions, to check the format
string against the argument string, for type mismatches, missing
arguments, and too many arguments.
In the CGI form argument parsing code, we needed to be more careful
about checking for bad input - good input is supposed to look like this:
name=value&name=value&.....
&name=value.  I don't think the original code
was checking properly for something like name&name=value.
There was another place where we were not checking to see if a buffer
had enough room before appending a string to it.
I had to change a couple of functions to allow passing in the size of
the buffer.
Fixed some issues raised by Noriko and Nathan.
Platforms tested: RHEL4
Flag Day: no
Doc impact: no
QA impact: should be covered by regular nightly and manual testing
New Tests integrated into TET: none



Index: certmap.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/lib/ldaputil/certmap.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- certmap.c	19 Apr 2005 22:07:45 -0000	1.5
+++ certmap.c	11 Apr 2006 02:14:53 -0000	1.6
@@ -46,6 +46,8 @@
 */
 #include <plstr.h>
 #include <prlink.h>
+#include <prprf.h>
+
 #include <key.h>
 #include <cert.h>
 #include <ldaputil/certmap.h>
@@ -388,7 +390,7 @@
 
 static void print_oid_bitmask (long bitmask)
 {
-    fprintf(stderr, "%x: ", bitmask);
+    fprintf(stderr, "%lx: ", bitmask);
 
     if (PresentInComps(bitmask, SEC_OID_AVA_COUNTRY_NAME))
 	fprintf(stderr, " C");
@@ -1812,7 +1814,7 @@
 
     *certmap_list = 0;
     *certmap_default = 0;
-    sprintf(this_dllname, "%s", dllname);
+    PR_snprintf(this_dllname, sizeof(this_dllname), "%s", dllname);
 
     if (!certmap_listinfo) return LDAPU_ERR_OUT_OF_MEMORY;
 


Index: init.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/lib/ldaputil/init.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- init.c	19 Apr 2005 22:07:45 -0000	1.6
+++ init.c	11 Apr 2006 02:14:53 -0000	1.7
@@ -39,6 +39,7 @@
 #include <string.h>
 #include <prlink.h>
 #include <prio.h>
+#include <prprf.h>
 
 /*#include "base/file.h"*/
 #include "ldaputil/certmap.h"
@@ -90,7 +91,7 @@
             if(is_lib) {
 		char path[1024];
 
-		sprintf(path, "%s%c%s", dir, FILE_PATHSEP, libname);
+		PR_snprintf(path, sizeof(path), "%s%c%s", dir, FILE_PATHSEP, libname);
 		lib = PR_LoadLibrary(path);
 		if (!lib) rv = LDAPU_ERR_UNABLE_TO_LOAD_PLUGIN;
 	    }
@@ -123,7 +124,7 @@
 
 	if (serv_root && *serv_root) {
 	    /* Load common libraries */
-	    sprintf(dir, "%s%clib%c%s", serv_root, FILE_PATHSEP,
+	    PR_snprintf(dir, sizeof(dir), "%s%clib%c%s", serv_root, FILE_PATHSEP,
 		    FILE_PATHSEP, "common");
 	    rv = load_server_libs(dir);
 


Index: ldapauth.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/lib/ldaputil/ldapauth.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ldapauth.c	19 Apr 2005 22:07:45 -0000	1.5
+++ ldapauth.c	11 Apr 2006 02:14:53 -0000	1.6
@@ -46,6 +46,7 @@
 #include <stdio.h>		/* for BUFSIZ */
 #include <string.h>		/* for strncpy, strcat */
 #include <ldap.h>
+#include <prprf.h>
 
 #include <ldaputil/certmap.h>
 #include <ldaputil/errors.h>
@@ -274,7 +275,7 @@
     int		retval;
 
     /* setup filter as (uid=<uid>) */
-    sprintf(filter, ldapu_strings[LDAPU_STR_FILTER_USER], uid);
+    PR_snprintf(filter, sizeof(filter), ldapu_strings[LDAPU_STR_FILTER_USER], uid);
 
     retval = ldapu_find(ld, base, scope, filter, attrs, attrsonly, res);
 
@@ -384,7 +385,7 @@
     int		retval;
 
     /* setup the filter */
-    sprintf(filter,
+    PR_snprintf(filter, sizeof(filter),
 	    ldapu_strings[LDAPU_STR_FILTER_GROUP],
 	    groupid);
 
@@ -497,7 +498,7 @@
 	return LDAPU_ERR_CIRCULAR_GROUPS;
 
     /* setup the filter */
-    sprintf(member_filter, ldapu_strings[LDAPU_STR_FILTER_MEMBER], userdn, userdn);
+    PR_snprintf(member_filter, sizeof(member_filter), ldapu_strings[LDAPU_STR_FILTER_MEMBER], userdn, userdn);
 
     retval = ldapu_find(ld, groupdn, LDAP_SCOPE_BASE, member_filter, attrs,
 			attrsonly, &res);
@@ -510,7 +511,7 @@
 	DBG_PRINT2("Find parent groups of \"%s\"\n", userdn);
 
 	/* Modify the filter to include the objectclass check */
-	sprintf(filter, ldapu_strings[LDAPU_STR_FILTER_MEMBER_RECURSE],
+	PR_snprintf(filter, sizeof(filter), ldapu_strings[LDAPU_STR_FILTER_MEMBER_RECURSE],
 		member_filter);
 	retval = ldapu_find(ld, base, LDAP_SCOPE_SUBTREE, filter,
 			    attrs, attrsonly, &res);
@@ -1020,9 +1021,9 @@
 
     /* setup filter as (& (uid=<uid>) (attrfilter)) */
     if (*attrfilter == '(') 
-	sprintf(filter, "(& (uid=%s) %s)", uid, attrfilter);
+	PR_snprintf(filter, sizeof(filter), "(& (uid=%s) %s)", uid, attrfilter);
     else
-	sprintf(filter, "(& (uid=%s) (%s))", uid, attrfilter);
+	PR_snprintf(filter, sizeof(filter), "(& (uid=%s) (%s))", uid, attrfilter);
 
     retval = ldapu_find(ld, base, scope, filter, attrs, attrsonly, &res);
 




More information about the Fedora-directory-commits mailing list