]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_fsr: ensure the line we read from leftofffile is null terminated
authorEric Sandeen <sandeen@sandeen.net>
Thu, 19 Jun 2014 02:12:36 +0000 (12:12 +1000)
committerDave Chinner <david@fromorbit.com>
Thu, 19 Jun 2014 02:12:36 +0000 (12:12 +1000)
Ensure that the string we read from leftofffile is NULL
terminated; the buffer gets passed to strchr(), so
it's important that we ensure it ends with NULL.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
fsr/xfs_fsr.c

index 3818f023627516617508b0b6c4baddadd9c9e7c0..94d235c7a74b62c47630d25087e54298c8d1f0db 100644 (file)
@@ -554,6 +554,8 @@ fsrallfs(char *mtab, int howlong, char *leftofffile)
                        fsrprintf(_("could not read %s, starting with %s\n"),
                                leftofffile, *fs->dev);
                } else {
+                       /* Ensure the buffer we read is null terminated */
+                       buf[SMBUFSZ-1] = '\0';
                        for (fs = fsbase; fs < fsend; fs++) {
                                fsname = fs->dev;
                                if ((strncmp(buf,fsname,strlen(fsname)) == 0)