Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 3 Mar 2006 03:36:26 +0200
From:      Giorgos Keramidas <keramida@ceid.upatras.gr>
To:        Craig Rodrigues <rodrigc@freebsd.org>
Cc:        freebsd-current@freebsd.org
Subject:   NULL pointer passed to printf() in sbin/mount/mount.c
Message-ID:  <20060303013626.GA10925@flame.pc>

next in thread | raw e-mail | index | archive | help
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@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@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@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@flame:/home/build/src/sbin/mount$

Any idea how the following core dump can be fixed for HEAD?

% build@flame:/home/build/src/sbin/mount$ export MAKEOBJDIRPREFIX=/home/build/obj
% build@flame:/home/build/src/sbin/mount$ export DEBUG_FLAGS='-g'
% build@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@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@flame:/home/build/src/sbin/mount$ make obj
% /home/build/obj/home/build/src/sbin/mount created for /home/build/src/sbin/mount
% build@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@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@flame:/home/build/src/sbin/mount$




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060303013626.GA10925>