* utilvfs.c (vfs_parse_ls_lga): Handle device without whitespace(s)

between major and minor.
This commit is contained in:
Andrew V. Samoilov 2004-03-07 06:17:12 +00:00
parent 02db8a9660
commit 722f4e684a
2 changed files with 13 additions and 5 deletions

View File

@ -1,5 +1,8 @@
2004-03-07 Andrew V. Samoilov <sav@bcs.zp.ua>
* utilvfs.c (vfs_parse_ls_lga): Handle device without whitespace(s)
between major and minor.
* direntry.c (vfs_s_resolve_symlink): Check vfs_s_fullpath()
return value to avoid NULL dereference.
Reported by wwp <subscript@free.fr>.

View File

@ -748,12 +748,17 @@ vfs_parse_ls_lga (const char *p, struct stat *s, char **filename,
if (S_ISCHR (s->st_mode) || S_ISBLK (s->st_mode)) {
int maj, min;
if (!is_num (idx2) || sscanf (columns[idx2], " %d,", &maj) != 1)
goto error;
if (!is_num (++idx2) || sscanf (columns[idx2], " %d", &min) != 1)
goto error;
/* Corner case: there is no whitespace(s) between maj & min */
if (!is_num (idx2) && idx2 == 2) {
if (!is_num (++idx2) || sscanf (columns[idx2], " %d,%d", &min, &min) != 2)
goto error;
} else {
if (!is_num (idx2) || sscanf (columns[idx2], " %d,", &maj) != 1)
goto error;
if (!is_num (++idx2) || sscanf (columns[idx2], " %d", &min) != 1)
goto error;
}
#ifdef HAVE_STRUCT_STAT_ST_RDEV
s->st_rdev = ((maj & 0xff) << 8) | (min & 0xffff00ff);
#endif