From f59ff311ca118ef73f469d87f1cc9c9547ee3ca1 Mon Sep 17 00:00:00 2001 From: Palmer Dabbelt Date: Mon, 2 Mar 2015 16:12:40 -0800 Subject: [PATCH] Check the result of a "sscanf" call This was being reported as a warning by GCC. The fix is trivial: just check the return code from sscanf and bail out of check_mount_line() whenever we don't get the right number of parsed elements. --- eyefi-linux.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/eyefi-linux.c b/eyefi-linux.c index b77a891..f7a0888 100644 --- a/eyefi-linux.c +++ b/eyefi-linux.c @@ -183,6 +183,10 @@ static char *check_mount_line(int line_nr, char *line) read = sscanf(&line[0], "%s %s %s %s %d %d", &dev[0], &mnt[0], &fs[0], &opt[0], &garb1, &garb2); + if (read != 6) { + debug_printf(2, "Unable to parse mount line: '%s'\n", line); + return NULL; + } // only look at fat filesystems: if (!fs_is(fs, "msdos") && !fs_is(fs, "vfat")) { debug_printf(4, "fs[%d] at '%s' is not fat, skipping...\n",