]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/fstab-util: immediately drop empty options again
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 10 Mar 2021 12:35:26 +0000 (13:35 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 11 Mar 2021 08:19:54 +0000 (09:19 +0100)
In the conversion from strv_split() to strv_split_full() done in
7bb553bb98a57b4e03804f8192bdc5a534325582, EXTRACT_DONT_COALESCE_SEPARATORS was
added. I think this was just by mistake… We never look for "empty options", so
whether we immediately ignore the extra separator or store the empty string in
strv, should make no difference.

src/shared/fstab-util.c
src/test/test-fstab-util.c

index 292b97cd6929b506ecef5f30e5ceeb80cc0a3dba..1ddcd371cfcf590c5b2d2464dc065d8872d38f7b 100644 (file)
@@ -140,7 +140,7 @@ int fstab_filter_options(const char *opts, const char *names,
                                 break;
                 }
         } else {
-                r = strv_split_full(&stor, opts, ",", EXTRACT_DONT_COALESCE_SEPARATORS | EXTRACT_UNESCAPE_SEPARATORS);
+                r = strv_split_full(&stor, opts, ",", EXTRACT_UNESCAPE_SEPARATORS);
                 if (r < 0)
                         return r;
 
index 222ffbb2a75b6b487d0c2ff11353d54b57cef67d..ebbdd05ca62d4d6a843c68e64523401f6de7ebad 100644 (file)
@@ -91,9 +91,13 @@ static void test_fstab_filter_options(void) {
         do_fstab_filter_options("opt =0", "x-opt\0opt\0noopt\0x-noopt\0", 0, NULL, NULL, NULL);
         do_fstab_filter_options(" opt ", "opt\0x-opt\0", 0, NULL, NULL, NULL);
 
-        /* check function will NULL args */
+        /* check function with NULL args */
         do_fstab_filter_options(NULL, "opt\0", 0, NULL, NULL, "");
         do_fstab_filter_options("", "opt\0", 0, NULL, NULL, "");
+
+        /* unnecessary comma separators */
+        do_fstab_filter_options("opt=x,,,,", "opt\0", 1, "opt", "x", "");
+        do_fstab_filter_options(",,,opt=x,,,,", "opt\0", 1, "opt", "x", "");
 }
 
 static void test_fstab_find_pri(void) {