summaryrefslogtreecommitdiffstats
path: root/lib/ldaputil/ldapauth.c
diff options
context:
space:
mode:
authorRich Megginson <rmeggins@redhat.com>2006-04-11 02:14:54 +0000
committerRich Megginson <rmeggins@redhat.com>2006-04-11 02:14:54 +0000
commite8c67e58c2faa3e3f5d328a92391a5a6a4569620 (patch)
tree7e16092b4dfb0106f446bb6a79552004399f7155 /lib/ldaputil/ldapauth.c
parent9545e36805201ac0e3172b762373c6df741c2721 (diff)
downloadds-e8c67e58c2faa3e3f5d328a92391a5a6a4569620.tar.gz
ds-e8c67e58c2faa3e3f5d328a92391a5a6a4569620.tar.xz
ds-e8c67e58c2faa3e3f5d328a92391a5a6a4569620.zip
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
Diffstat (limited to 'lib/ldaputil/ldapauth.c')
-rw-r--r--lib/ldaputil/ldapauth.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/ldaputil/ldapauth.c b/lib/ldaputil/ldapauth.c
index 40ee9e77..dd062be6 100644
--- a/lib/ldaputil/ldapauth.c
+++ b/lib/ldaputil/ldapauth.c
@@ -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 ldapu_find_uid_attrs (LDAP *ld, const char *uid, const char *base,
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 ldapu_find_group_attrs (LDAP *ld, const char *groupid,
int retval;
/* setup the filter */
- sprintf(filter,
+ PR_snprintf(filter, sizeof(filter),
ldapu_strings[LDAPU_STR_FILTER_GROUP],
groupid);
@@ -497,7 +498,7 @@ int ldapu_auth_udn_gdn_recurse (LDAP *ld, const char *userdn,
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 @@ int ldapu_auth_udn_gdn_recurse (LDAP *ld, const char *userdn,
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 @@ int ldapu_auth_uid_attrfilter (LDAP *ld, const char *uid, const char *attrfilter
/* 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);