From: Gustavo Sverzut Barbieri Date: Mon, 19 Dec 2011 19:42:34 +0000 (-0200) Subject: elf: do not output empty strings. X-Git-Tag: v2~33 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=47a0ef6;p=thirdparty%2Fkmod.git elf: do not output empty strings. --- diff --git a/libkmod/libkmod-elf.c b/libkmod/libkmod-elf.c index 0cb12edb..85395dc6 100644 --- a/libkmod/libkmod-elf.c +++ b/libkmod/libkmod-elf.c @@ -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';