kauth: Don't overflow cellinfo hostAddrs array
authorSimon Wilkinson <sxw@your-file-system.com>
Fri, 1 Mar 2013 11:22:26 +0000 (11:22 +0000)
committerDerrick Brashear <shadow@your-file-system.com>
Mon, 4 Mar 2013 03:01:22 +0000 (19:01 -0800)
The hostaddrs array has MAXHOSTSPERCELL (8) available elements.
The ubik connections list has MAXSERVERS (20) elements - when copying
from the ubik list into the cellinfo hostaddrs list, be careful not
to overflow it.

Caught by coverity (#985577)

Change-Id: Ie51cb939a6e3381a285787ad125342ca7a9e7cbb
Reviewed-on: http://gerrit.openafs.org/9323
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/kauth/kaserver.c

index 2fca96a..816871c 100644 (file)
@@ -344,6 +344,11 @@ main(int argc, char *argv[])
        for (i = 1; i < MAXSERVERS; i++) {
            if (!serverList[i])
                break;
+           if (i >= MAXHOSTSPERCELL) {
+               fprintf(stderr,
+                       "Too many ubik servers specified on command line\n");
+               exit(1);
+           }
            cellinfo.hostAddr[i].sin_addr.s_addr = serverList[i];
        }
        cellinfo.numServers = i;