If /sys isn't mounted or the loop device is disassociated between
reading /proc/mounts and asking for follow-up data from sysfs, readfile() returns NULL and there should have been an else case setting it back to "" instead of NULL so the printf() and if (!*ss) free(ss) didn't try to dereference the NULL. That said, the initial "" was only specutavely replaced and then needing to be put back because code really wants a third variable, and I can re-use s if I move the xabspath() down a bit, so...
This commit is contained in:
parent
c1fb95a3d8
commit
d298747580
@ -373,24 +373,24 @@ void mount_main(void)
|
||||
// show mounts from /proc/mounts
|
||||
} else if (!dev) {
|
||||
for (mtl = xgetmountlist(0); mtl && (mm = dlist_pop(&mtl)); free(mm)) {
|
||||
char *s = mm->device, *ss = "";
|
||||
char *s = mm->device, *ss = "", *temp;
|
||||
struct stat st;
|
||||
|
||||
if (TT.t && strcmp(TT.t, mm->type)) continue;
|
||||
if (*s == '/') {
|
||||
s = xabspath(mm->device, 0);
|
||||
if (!stat(s, &st) && S_ISBLK(st.st_mode) &&dev_major(st.st_rdev)==7) {
|
||||
char *temp = xmprintf("/sys/block/loop%d/loop/backing_file",
|
||||
if (!stat(mm->device, &st) && S_ISBLK(st.st_mode) &&
|
||||
dev_major(st.st_rdev)==7)
|
||||
{
|
||||
temp = xmprintf("/sys/block/loop%d/loop/backing_file",
|
||||
dev_minor(st.st_rdev));
|
||||
|
||||
ss = chomp(readfile(temp, 0, 0));
|
||||
s = chomp(readfile(temp, 0, 0));
|
||||
free(temp);
|
||||
if (ss) {
|
||||
temp = xmprintf(",file=%s"+!*mm->opts, ss);
|
||||
free(ss);
|
||||
ss = temp;
|
||||
}
|
||||
if (s) {
|
||||
ss = xmprintf(",file=%s"+!*mm->opts, s);
|
||||
free(s);
|
||||
};
|
||||
}
|
||||
s = xabspath(mm->device, 0);
|
||||
}
|
||||
xprintf("%s on %s type %s (%s%s)\n", s, mm->dir, mm->type, mm->opts, ss);
|
||||
if (s != mm->device) free(s);
|
||||
|
Loading…
Reference in New Issue
Block a user