Skip to content

Commit fe50760

Browse files
committed
Apply advices Finn Thain at genext2fs mail-list
1 parent 19e860e commit fe50760

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

genext2fs.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,17 +1545,21 @@ add2fs_from_file(filesystem *fs, uint32 this_nod, FILE * fh, uint32 fs_timestamp
15451545
}
15461546

15471547
// `sscanf()` is used twice to allow to have `#` character in the file path
1548-
if(line[0] == '\n' || line[0] == '#')
1549-
continue;
1550-
nbargs = sscanf(line, "%" SCANF_PREFIX "s", SCANF_STRING(path));
1551-
if(!nbargs)
1548+
nbargs = sscanf(line, " %" SCANF_PREFIX "s", SCANF_STRING(path));
1549+
if(nbargs < 1)
15521550
{
15531551
error_msg("device table line %d skipped: file path not provided", lineno);
15541552
continue;
15551553
}
1554+
if(path[0] == '#') // Line is a comment, ignore it
1555+
continue;
1556+
1557+
// Search a `#` at the line after the path (it's a comment, ignore it)
15561558
char* line2 = line+strlen(path);
15571559
if((c = strchr(line2, '#')))
15581560
*c = 0;
1561+
1562+
// Fetch the path stat attributes
15591563
nbargs = sscanf(line2, " %c %lo %lu %lu %lu %lu %lu %lu %lu", &type, &mode,
15601564
&uid, &gid, &major, &minor, &start, &increment, &count);
15611565
if(nbargs < 2)

0 commit comments

Comments
 (0)