|
Message-ID: <7665137.oDFzTOozpa@nimes> Date: Mon, 19 Aug 2024 16:46:23 +0200 From: Bruno Haible <bruno@...sp.org> To: musl@...ts.openwall.com Subject: hasmntopt function returns non-NULL when it shouldn't Hi, The hasmntopt() function is documented in https://www.gnu.org/software/libc/manual/html_node/mtab.html and https://man7.org/linux/man-pages/man3/hasmntopt.3.html The implementation of this function in musl libc 1.2.5 returns a non-NULL value also for some options that do *not* occur in the mount options string. How to reproduce: =============================== has.c =============================== #include <mntent.h> #include <string.h> #include <assert.h> int main () { char options[] = "rw,nosuid,nodev,noexec,noatime,size=5120k,inode64"; struct mntent me; me.mnt_opts = options; assert (hasmntopt (&me, "ro") == NULL); assert (hasmntopt (&me, "rw") == options + 0); assert (hasmntopt (&me, "atime") == NULL); assert (hasmntopt (&me, "no") == NULL); assert (hasmntopt (&me, "noatime") == options + 23); assert (hasmntopt (&me, "size") == options + 31); assert (hasmntopt (&me, "size=512") == NULL); assert (hasmntopt (&me, "size=5120k") == options + 31); assert (hasmntopt (&me, "inode64") == options + 42); return 0; } ===================================================================== $ gcc -Wall has.c $ ./a.out Expected result: No assertion failure. Like on glibc. Actual result: Assertion failed: hasmntopt (&me, "atime") == NULL (has.c: main: 14) The mount options "atime" and "noatime" are pretty much the opposite of each other (see https://man7.org/linux/man-pages/man8/mount.8.html). Therefore in a program that tests for the "atime" option, it is wrong to return the equivalent of true when the options string contains "noatime", not "atime". Bruno
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.