fsck.f2fs: fix to use strncmp to avoid out-of-boundary access
Otherwise, if length of main device path is equal to MAX_PATH_LEN,
it will trigger assert() as below:
[ASSERT] (init_sb_info:1264) !strcmp((char *)sb->devs[i].path, (char *)c.devices[i].path)
This is because there is no null character in the end of devcie
path string, result in out-of-boundary access in devs.path[].
Let's use strncmp instead of strcmp to compare device path to fix
this issue.
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
diff --git a/fsck/mount.c b/fsck/mount.c
index dbbeb56..a1c4cbb 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -1261,8 +1261,9 @@
if (get_device_info(i))
ASSERT(0);
} else if (c.func != INJECT) {
- if (strcmp((char *)sb->devs[i].path,
- (char *)c.devices[i].path)) {
+ if (strncmp((char *)sb->devs[i].path,
+ (char *)c.devices[i].path,
+ MAX_PATH_LEN)) {
MSG(0, "paths mismatch: %s, %s\n",
(char *)sb->devs[i].path,
(char *)c.devices[i].path);