]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
elf: do not output empty strings.
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Mon, 19 Dec 2011 19:42:34 +0000 (17:42 -0200)
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Mon, 19 Dec 2011 20:32:58 +0000 (18:32 -0200)
libkmod/libkmod-elf.c

index 0cb12edb77c79e8071c7f8cd6ed6ed72141d4ccf..85395dc6b1a2afec89e6adb0dd24ae94f2a5cdca 100644 (file)
@@ -418,9 +418,16 @@ int kmod_elf_get_strings(const struct kmod_elf *elf, const char *section, char *
        if (size <= 1)
                return 0;
 
+       last = 0;
        for (i = 0, count = 0; i < size; i++) {
-               if (strings[i] == '\0')
+               if (strings[i] == '\0') {
+                       if (last == i) {
+                               last = i + 1;
+                               continue;
+                       }
                        count++;
+                       last = i + 1;
+               }
        }
        if (strings[i - 1] != '\0')
                count++;
@@ -434,6 +441,10 @@ int kmod_elf_get_strings(const struct kmod_elf *elf, const char *section, char *
        for (i = 0, count = 0; i < size; i++) {
                if (strings[i] == '\0') {
                        size_t slen = i - last;
+                       if (last == i) {
+                               last = i + 1;
+                               continue;
+                       }
                        a[count] = itr;
                        memcpy(itr, strings + last, slen);
                        itr[slen] = '\0';