unlog: Don't overflow cells array
authorSimon Wilkinson <sxw@your-file-system.com>
Fri, 1 Mar 2013 11:31:31 +0000 (11:31 +0000)
committerDerrick Brashear <shadow@your-file-system.com>
Mon, 4 Mar 2013 03:01:52 +0000 (19:01 -0800)
cells has a maximum size of MAXCELLS. Doing cells[MAXCELLS] overflows
that array. Clamp our maximum number of cells at one below this to
avoid the overflow.

Caught by coverity (#98551)

Change-Id: I45fd8a55e31ad7ea86a996b593359536c7078891
Reviewed-on: http://gerrit.openafs.org/9324
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/log/unlog.c

index f2760aa..f9ee1c8 100644 (file)
@@ -65,7 +65,7 @@ CommandProc(struct cmd_syndesc *as, void *arock)
 
     if (as->parms[0].items) {  /* A cell is provided */
        for (itp = as->parms[0].items; itp; itp = itp->next) {
-           if (i > MAXCELLS) {
+           if (i >= MAXCELLS) {
                printf
                    ("The maximum number of cells (%d) is exceeded; the rest are ignored\n",
                     MAXCELLS);