auth: Don't overflow lower case cell string
authorSimon Wilkinson <sxw@your-file-system.com>
Sun, 3 Mar 2013 17:47:49 +0000 (17:47 +0000)
committerDerrick Brashear <shadow@your-file-system.com>
Mon, 11 Mar 2013 14:27:39 +0000 (07:27 -0700)
When building tcell_l in kerberosSuperUser, make sure that we
don't overflow the string that we're constructing.

Use the opr_lcstring function to do the lower case conversion,
rather than rolling our own.

Caught by coverity (#985772)

Change-Id: I6e28cfc54883aac7e3a3eb2f4e2b2bf7ebc0bc63
Reviewed-on: http://gerrit.openafs.org/9544
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

src/auth/userok.c

index f66acf1..ff88fc4 100644 (file)
@@ -597,20 +597,13 @@ kerberosSuperUser(struct afsconf_dir *adir, char *tname, char *tinst,
                  char *tcell, struct rx_identity **identity)
 {
     char tcell_l[MAXKTCREALMLEN] = "";
-    char *tmp;
     int code;
     afs_int32 islocal;
     int flag;
 
     /* generate lowercased version of cell name */
-    if (tcell) {
-       strcpy(tcell_l, tcell);
-       tmp = tcell_l;
-       while (*tmp) {
-           *tmp = tolower(*tmp);
-           tmp++;
-       }
-    }
+    if (tcell)
+       opr_lcstring(tcell_l, tcell, sizeof(tcell_l));
 
     code = afsconf_IsLocalRealmMatch(adir, &islocal, tname, tinst, tcell);
     if (code) {