udhcpc: fix a problem with binary-encoded options #2
[oweals/busybox.git] / modutils / modinfo.c
index c0910ffedffbac700a85fbfb43e94ce9c7d7744c..7c978d1da50ad68a4eb66d3e0dcc1ff20f9e56d7 100644 (file)
@@ -24,9 +24,9 @@
 
 
 enum {
-       OPT_TAGS = (1 << 8) - 1,
-       OPT_F = (1 << 8), /* field name */
-       OPT_0 = (1 << 9),  /* \0 as separator */
+       OPT_TAGS = (1 << 12) - 1, /* shortcut count */
+       OPT_F = (1 << 12), /* field name */
+       OPT_0 = (1 << 13), /* \0 as separator */
 };
 
 struct modinfo_env {
@@ -49,13 +49,17 @@ static void modinfo(const char *path, const char *version,
 {
        static const char *const shortcuts[] = {
                "filename",
-               "description",
-               "author",
                "license",
+               "author",
+               "description",
+               "version",
+               "alias",
+               "srcversion",
+               "depends",
+               "uts_release",
                "vermagic",
                "parm",
                "firmware",
-               "depends",
        };
        size_t len;
        int j, length;
@@ -97,8 +101,11 @@ static void modinfo(const char *path, const char *version,
                        if (ptr == NULL) /* no occurance left, done */
                                break;
                        if (strncmp(ptr, pattern, length) == 0 && ptr[length] == '=') {
-                               ptr += length + 1;
-                               ptr += display(ptr, pattern, (1<<j) != tags);
+                               /* field prefixes are 0x80 or 0x00 */
+                               if ((ptr[-1] & 0x7F) == '\0') {
+                                       ptr += length + 1;
+                                       ptr += display(ptr, pattern, (1<<j) != tags);
+                               }
                        }
                        ++ptr;
                }
@@ -131,7 +138,7 @@ int modinfo_main(int argc UNUSED_PARAM, char **argv)
 
        env.field = NULL;
        opt_complementary = "-1"; /* minimum one param */
-       opts = getopt32(argv, "fdalvpF:0", &env.field);
+       opts = getopt32(argv, "nladvAsDumpF:0", &env.field);
        env.tags = opts & OPT_TAGS ? opts & OPT_TAGS : OPT_TAGS;
        argv += optind;