[Fedora-directory-commits] ldapserver/ldap/clients/orgchart wrapper.c, 1.4, 1.5

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


Author: rmeggins

Update of /cvs/dirsec/ldapserver/ldap/clients/orgchart
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv8136/ldapserver/ldap/clients/orgchart

Modified Files:
	wrapper.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: wrapper.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/clients/orgchart/wrapper.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- wrapper.c	19 Apr 2005 22:07:20 -0000	1.4
+++ wrapper.c	11 Apr 2006 02:14:33 -0000	1.5
@@ -62,7 +62,7 @@
 #define PATH_MAX 512
 #endif
 
-char *get_perl_file(char *);
+char *get_perl_file(char *, size_t);
 
 
 /*
@@ -77,7 +77,7 @@
 
   printf("Content-type:text/html;charset=UTF-8\n\n<html>Hi\n");
 
-  get_perl_file(script);
+  get_perl_file(script, sizeof(script)-1);
   
   if (strchr(script, '/') != NULL || strchr(script, '\\') != NULL) {
     printf("Paths not allowed. Filenames only.\n");
@@ -94,10 +94,11 @@
 }
 
 char *
-get_perl_file(char *script) {
+get_perl_file(char *script, size_t scriptsize) {
   char *qs = getenv("QUERY_STRING");
   char *p1 = NULL;
   char *p2 = NULL;
+  size_t maxsize;
   
   if (qs == NULL || *qs == '\0') {
     printf("No QUERY_STRING found\n");
@@ -113,6 +114,8 @@
 
   for (p2 = p1; *p2 != '\0' && *p2 != '&'; p2++);
 
-  strncpy(script, p1, p2-p1);
-  script[p2-p1] = '\0';
+  maxsize = (scriptsize < (p2-p1)) ? scriptsize : (p2-p1);
+
+  PL_strncpyz(script, p1, maxsize);
+  script[maxsize] = '\0';
 }




More information about the Fedora-directory-commits mailing list