From: Eric Sandeen Date: Thu, 19 Jun 2014 02:12:36 +0000 (+1000) Subject: xfs_fsr: ensure the line we read from leftofffile is null terminated X-Git-Tag: v3.2.1~18 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=eef20df010f3a89b2ce7021968beeeb5f3afe4f2;p=thirdparty%2Fxfsprogs-dev.git xfs_fsr: ensure the line we read from leftofffile is null terminated 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 Reviewed-by: Dave Chinner Signed-off-by: Dave Chinner --- diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c index 3818f0236..94d235c7a 100644 --- a/fsr/xfs_fsr.c +++ b/fsr/xfs_fsr.c @@ -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)