From: Zubair Lutfullah Kakakhel Date: Tue, 17 Jul 2018 18:25:38 +0000 (+0100) Subject: hashtable: Fix length calculation in hexport_r X-Git-Tag: v2018.09-rc1~42 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=f1b20acb4a03fc6ef5ebff18293287506348955d;p=oweals%2Fu-boot.git hashtable: Fix length calculation in hexport_r The length returned by hexport_r has a few redundant characters. This appears as NULL characters at the end so seems harmless. Remove the surplus counts in two places totlen += strlen(ep->key) + 2; I'm guessing the +2 here is for = and sep char. But there is another totlen += 2; line that does that. size = totletn + 1; Doesn't make sense and isn't justified with any comment. Signed-off-by: Zubair Lutfullah Kakakhel --- diff --git a/lib/hashtable.c b/lib/hashtable.c index ffaa5b6e4b..1c48692b69 100644 --- a/lib/hashtable.c +++ b/lib/hashtable.c @@ -622,7 +622,7 @@ ssize_t hexport_r(struct hsearch_data *htab, const char sep, int flag, list[n++] = ep; - totlen += strlen(ep->key) + 2; + totlen += strlen(ep->key); if (sep == '\0') { totlen += strlen(ep->data); @@ -662,7 +662,7 @@ ssize_t hexport_r(struct hsearch_data *htab, const char sep, int flag, return (-1); } } else { - size = totlen + 1; + size = totlen; } /* Check if the user provided a buffer */