NULL pointer passed to printf() in sbin/mount/mount.c
Giorgos Keramidas
keramida at ceid.upatras.gr
Fri Mar 3 01:37:24 GMT 2006
Hi Craig & -current,
After a recent update to HEAD, I noticed that ``mount -p'' no longer
prints the flags of the mounted filesystems correctly:
keramida at flame:/home/keramida$ mount -p
/dev/ad0s2a / ufs (null) 1 1
devfs /dev devfs (null) 0 0
/dev/ad0s2d /var ufs (null) 2 2
/dev/ad0s2e /usr ufs (null) 2 2
/dev/ad0s2f /home ufs (null) 2 2
/dev/md0 /tmp ufs (null) 2 2
devfs /var/named/dev devfs (null) 0 0
keramida at flame:/home/keramida$
Here ``(null)'' seems to be the output of a printf %s format which got a
NULL pointer. The following patch for src/sbin/mount/mount.c triggers
an assertion quite reproducibly:
% build at flame:/home/build/src/sbin/mount$ svn di
% Index: mount.c
% ===================================================================
% --- mount.c (revision 23)
% +++ mount.c (working copy)
% @@ -46,6 +46,7 @@
% #include <sys/stat.h>
% #include <sys/wait.h>
%
% +#include <assert.h>
% #include <ctype.h>
% #include <err.h>
% #include <errno.h>
% @@ -754,6 +755,7 @@
% char *opts;
%
% opts = flags2opts(ent->f_flags);
% + assert(opts != NULL);
% printf("%s\t%s\t%s %s", ent->f_mntfromname, ent->f_mntonname,
% ent->f_fstypename, opts);
% free(opts);
% build at flame:/home/build/src/sbin/mount$
Any idea how the following core dump can be fixed for HEAD?
% build at flame:/home/build/src/sbin/mount$ export MAKEOBJDIRPREFIX=/home/build/obj
% build at flame:/home/build/src/sbin/mount$ export DEBUG_FLAGS='-g'
% build at flame:/home/build/src/sbin/mount$ make cleandir
% rm -f mount mount.o mount_fs.o getmntopts.o vfslist.o mount.8.gz mount.8.cat.gz
% rm -f .depend GPATH GRTAGS GSYMS GTAGS
% build at flame:/home/build/src/sbin/mount$ make cleandir
% rm -f mount mount.o mount_fs.o getmntopts.o vfslist.o mount.8.gz mount.8.cat.gz
% rm -f .depend GPATH GRTAGS GSYMS GTAGS
% build at flame:/home/build/src/sbin/mount$ make obj
% /home/build/obj/home/build/src/sbin/mount created for /home/build/src/sbin/mount
% build at flame:/home/build/src/sbin/mount$ make
% cc -O2 -fno-strict-aliasing -pipe -g -Wsystem-headers -Werror -Wall \
% -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes \
% -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual \
% -Wwrite-strings -Wswitch -Wshadow -Wcast-align -Wunused-parameter \
% -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls \
% -c /home/build/src/sbin/mount/mount.c
% cc -O2 -fno-strict-aliasing -pipe -g -Wsystem-headers -Werror -Wall \
% -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes \
% -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual \
% -Wwrite-strings -Wswitch -Wshadow -Wcast-align -Wunused-parameter \
% -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls \
% -c /home/build/src/sbin/mount/mount_fs.c
% cc -O2 -fno-strict-aliasing -pipe -g -Wsystem-headers -Werror -Wall \
% -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes \
% -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual \
% -Wwrite-strings -Wswitch -Wshadow -Wcast-align -Wunused-parameter \
% -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls \
% -c /home/build/src/sbin/mount/getmntopts.c
% cc -O2 -fno-strict-aliasing -pipe -g -Wsystem-headers -Werror -Wall \
% -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes \
% -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual \
% -Wwrite-strings -Wswitch -Wshadow -Wcast-align -Wunused-parameter \
% -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls \
% -c /home/build/src/sbin/mount/vfslist.c
% cc -O2 -fno-strict-aliasing -pipe -g -Wsystem-headers -Werror -Wall \
% -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes \
% -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual \
% -Wwrite-strings -Wswitch -Wshadow -Wcast-align -Wunused-parameter \
% -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls \
% -o mount mount.o mount_fs.o getmntopts.o vfslist.o
% gzip -cn /home/build/src/sbin/mount/mount.8 > mount.8.gz
% build at flame:/home/build/src/sbin/mount$ /home/build/obj/home/build/src/sbin/mount/mount -p
% Assertion failed: (opts != NULL), function putfsent, file /home/build/src/sbin/mount/mount.c, line 758.
% Abort trap: 6 (core dumped)
% build at flame:/home/build/src/sbin/mount$
More information about the freebsd-current
mailing list