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.
This commit is contained in:
Palmer Dabbelt 2015-03-02 16:12:40 -08:00 committed by Dave Hansen
parent 0bf79af0f6
commit f59ff311ca

View file

@ -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",