bos_util: Fix buffer overflow
authorSimon Wilkinson <sxw@your-file-system.com>
Tue, 26 Feb 2013 21:30:20 +0000 (21:30 +0000)
committerJeffrey Altman <jaltman@your-file-system.com>
Wed, 27 Feb 2013 20:39:23 +0000 (12:39 -0800)
Get rid of a buffer overflow in the bos_util utility, by just
printing the key from the 'tbuffer' string, rather than copying
it into 'x' which is too small for it.

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

src/bozo/bos_util.c

index 2a7e62a..62293a2 100644 (file)
@@ -180,13 +180,11 @@ main(int argc, char **argv)
        for (i = 0; i < tkeys.nkeys; i++) {
            if (tkeys.key[i].kvno != -1) {
                int count;
-               unsigned char x[8];
                memcpy(tbuffer, tkeys.key[i].key, 8);
                tbuffer[8] = 0;
                printf("kvno %4d: key is '%s' '", tkeys.key[i].kvno, tbuffer);
-               strcpy((char *)x, (char *)tbuffer);
                for (count = 0; count < 8; count++)
-                   printf("\\%03o", x[count]);
+                   printf("\\%03o", tbuffer[count]);
                printf("'\n");
            }
        }