diff options
author | Tom Rini <trini@konsulko.com> | 2017-08-20 20:05:40 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2017-08-26 14:56:13 -0400 |
commit | bc028345acc44a4fe94fd0572ab0552bdfb7f810 (patch) | |
tree | dffabb67a38d87800381c45d5915bd9aa7e8d1d1 /cmd | |
parent | 1e87f9ced4db17d2e06db5a9af6cd89ca680957a (diff) |
mtdparts: Fix final outstanding issue reported by Coverity
As part of fixing the previously reported issues, it was missed that in
the case of mtdparts_init() we need to make sure that tmp_ep is long
enough to contain PARTITION_MAXLEN and a NULL termination. Then, to be
sure the buffer is NULL terminated, zero the entire buffer rather than
just ensuring the first character is NULL.
Cc: Lothar Waßmann <LW@KARO-electronics.de>
Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
Reported-by: Coverity (CID: 166329)
Signed-off-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/mtdparts.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/cmd/mtdparts.c b/cmd/mtdparts.c index 72bff92a9ae..6e12275b408 100644 --- a/cmd/mtdparts.c +++ b/cmd/mtdparts.c @@ -1726,7 +1726,7 @@ int mtdparts_init(void) const char *ids, *parts; const char *current_partition; int ids_changed; - char tmp_ep[PARTITION_MAXLEN]; + char tmp_ep[PARTITION_MAXLEN + 1]; char tmp_parts[MTDPARTS_MAXLEN]; debug("\n---mtdparts_init---\n"); @@ -1750,7 +1750,7 @@ int mtdparts_init(void) /* save it for later parsing, cannot rely on current partition pointer * as 'partition' variable may be updated during init */ - tmp_ep[0] = '\0'; + memset(tmp_parts, 0, sizeof(tmp_parts)); if (current_partition) strncpy(tmp_ep, current_partition, PARTITION_MAXLEN); |