Whamcloud - gitweb
LU-2074 build: fix 'copy into fixed size buffer' errors
[fs/lustre-release.git] / lustre / utils / mount_utils_ldiskfs.c
index 4c75200..728c349 100644 (file)
@@ -1130,9 +1130,17 @@ static char *absolute_path(char *devname)
                        return NULL;
                }
                strcat(buf, "/");
-               strcat(buf, devname);
+               if (strlen(devname) > sizeof(buf)-strlen(buf)-1) {
+                       free(path);
+                       return NULL;
+               }
+               strncat(buf, devname, sizeof(buf)-strlen(buf)-1);
        } else {
-               strcpy(buf, devname);
+               if (strlen(devname) > sizeof(buf)-1) {
+                       free(path);
+                       return NULL;
+               }
+               strncpy(buf, devname, sizeof(buf));
        }
        /* truncate filename before calling realpath */
        ptr = strrchr(buf, '/');