aklog: Fix buffer overflows in next_path
authorSimon Wilkinson <sxw@your-file-system.com>
Sat, 2 Mar 2013 12:21:06 +0000 (12:21 +0000)
committerJeffrey Altman <jaltman@your-file-system.com>
Sun, 10 Mar 2013 03:16:39 +0000 (19:16 -0800)
Use strlcpy and strlcat

Caught by coverity (#985765)

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

src/aklog/aklog.c

index cc77753..0d0919f 100644 (file)
@@ -1172,7 +1172,7 @@ next_path(char *origpath)
     if (origpath) {
        memset(path, 0, sizeof(path));
        memset(pathtocheck, 0, sizeof(pathtocheck));
-       strcpy(path, origpath);
+       strlcpy(path, origpath, sizeof(path));
        last_comp = path;
        symlinkcount = 0;
        return(NULL);
@@ -1203,7 +1203,7 @@ next_path(char *origpath)
 
            memset(tmpbuf, 0, sizeof(tmpbuf));
            if (elast_comp)
-               strcpy(tmpbuf, elast_comp);
+               strlcpy(tmpbuf, elast_comp, sizeof(tmpbuf));
            if (linkbuf[0] == DIR) {
                /*
                 * If this is a symbolic link to an absolute path,