From 47a0ef601dc70c88b9008e35a688c900e4ebcfd4 Mon Sep 17 00:00:00 2001 From: Gustavo Sverzut Barbieri Date: Mon, 19 Dec 2011 17:42:34 -0200 Subject: [PATCH] elf: do not output empty strings. --- libkmod/libkmod-elf.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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'; -- 2.47.2