udhcpc: fix a problem with binary-encoded options #2
[oweals/busybox.git] / modutils / modinfo.c
index 410b6fbe4425744d6211580aea8ecf18a3c1d5c3..7c978d1da50ad68a4eb66d3e0dcc1ff20f9e56d7 100644 (file)
@@ -13,6 +13,7 @@
 //config:config MODINFO
 //config:      bool "modinfo"
 //config:      default y
+//config:      select PLATFORM_LINUX
 //config:      help
 //config:        Show information about a Linux Kernel module
 
@@ -23,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 {
@@ -48,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;
@@ -96,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;
                }
@@ -130,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;