[Fedora-directory-commits] ldapserver/lib/base dns.cpp, 1.5, 1.6 dnsdmain.cpp, 1.6, 1.7 file.cpp, 1.5, 1.6 plist.cpp, 1.4, 1.5 pool.cpp, 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/base
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv8136/ldapserver/lib/base

Modified Files:
	dns.cpp dnsdmain.cpp file.cpp plist.cpp pool.cpp 
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: dns.cpp
===================================================================
RCS file: /cvs/dirsec/ldapserver/lib/base/dns.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- dns.cpp	19 Apr 2005 22:07:45 -0000	1.5
+++ dns.cpp	11 Apr 2006 02:14:52 -0000	1.6
@@ -109,7 +109,9 @@
 
     err = PR_InitializeNetAddr(PR_IpAddrNull, 0, &iaddr);
 
-    if((iaddr.inet.ip = inet_addr(ip)) == -1)
+	/* richm: ipv6 cleanup - use inet_aton or other more appropriate function
+	   instead of inet_addr */
+    if((iaddr.inet.ip = inet_addr(ip)) == (in_addr_t)-1)
         goto bong;
 
     /*


Index: dnsdmain.cpp
===================================================================
RCS file: /cvs/dirsec/ldapserver/lib/base/dnsdmain.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- dnsdmain.cpp	10 May 2005 23:17:04 -0000	1.6
+++ dnsdmain.cpp	11 Apr 2006 02:14:52 -0000	1.7
@@ -177,7 +177,7 @@
 
     if (domain != 0) {
 	hnlen = strlen(hname);
-	if ((hnlen + dnlen + 2) <= sizeof(line)) {
+	if ((size_t)(hnlen + dnlen + 2) <= sizeof(line)) {
 	    strcpy(line, hname);
 	    line[hnlen] = '.';
 	    strcpy(&line[hnlen+1], domain);


Index: file.cpp
===================================================================
RCS file: /cvs/dirsec/ldapserver/lib/base/file.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- file.cpp	19 Apr 2005 22:07:45 -0000	1.5
+++ file.cpp	11 Apr 2006 02:14:52 -0000	1.6
@@ -543,23 +543,6 @@
 
 #include "util.h"
 
-static char *_errmsg_new(int code)
-{
-    char *ret;
-#ifdef THREAD_ANY
-    if(!(ret = (char *) systhread_getdata(errmsg_key))) {
-        ret = (char *) PERM_MALLOC(256);
-        systhread_setdata(errmsg_key, (void *)ret);
-    }
-#else
-    ret = errmsg;
-#endif
-    util_snprintf(ret, ERRMSG_SIZE, "libsec code %d", code);
-#ifndef MCC_BATMAN
-    PR_SetError(0,0);
-#endif
-    return ret;
-}
 #endif
 
 
@@ -611,7 +594,7 @@
             PR_SetError(0, 0);
             lmsg = nscp_error_msg;
         } else {
-            util_snprintf(static_error, ERRMSG_SIZE, "unknown error %d", nscp_error);
+            util_snprintf(static_error, sizeof(static_error), "unknown error %d", nscp_error);
             lmsg = static_error;
         }
     } else {


Index: plist.cpp
===================================================================
RCS file: /cvs/dirsec/ldapserver/lib/base/plist.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- plist.cpp	19 Apr 2005 22:07:45 -0000	1.4
+++ plist.cpp	11 Apr 2006 02:14:52 -0000	1.5
@@ -818,7 +818,7 @@
 
                     /* Is it time to grow the hash table? */
                     i = PLSIZENDX(pt->pt_sizendx);
-                    if ((pt->pt_sizendx < PLMAXSIZENDX) &&
+                    if (((size_t)pt->pt_sizendx < PLMAXSIZENDX) &&
                         pt->pt_nsyms >= (i + i)) {
 
                         PLSymbolTable_t *npt;


Index: pool.cpp
===================================================================
RCS file: /cvs/dirsec/ldapserver/lib/base/pool.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- pool.cpp	19 Apr 2005 22:07:45 -0000	1.5
+++ pool.cpp	11 Apr 2006 02:14:52 -0000	1.6
@@ -195,7 +195,7 @@
 	memset(block->data, 0xa, block->end-block->data);
 #endif /* POOL_ZERO_DEBUG */
 
-	if ((freelist_size + block->end - block->data) > freelist_max) {
+	if ((unsigned long)(freelist_size + block->end - block->data) > freelist_max) {
 		/* Just have to delete the whole block! */
 
 		crit_enter(freelist_lock);
@@ -452,7 +452,7 @@
 	pool_t *pool = (pool_t *)pool_handle;
 	void *newptr;
 	block_t *block_ptr;
-	int oldsize;
+	size_t oldsize;
 
 	if (pool_handle == NULL || pool_disable)
 		return PERM_REALLOC(ptr, size);




More information about the Fedora-directory-commits mailing list