summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2017-10-07 11:27:59 -0400
committerTom Rini <trini@konsulko.com>2017-10-07 11:27:59 -0400
commitbf52fcdef4aac242b5e6b6b9827acf6d69ce1951 (patch)
treececa9d544b473499e659bd04c77432dac29df0ae /cmd
parent83e92f79d3abe520f30bbd958c2b5068c049caf0 (diff)
cmd/gpt.c, cmd/nvedit.c, tools/fit_image.c: Rework recent fixes for Coverity
The recent changes to these files did not completely fix the previous issues, or introduced different (minor) issues. In cmd/gpt.c we need to dereference str_disk_guid to be sure that malloc worked. In cmd/nvedit.c we need to be careful that we can also fit in that leading space when adding to the string. And in tools/fit_image.c we need to re-work the error handling slightly in fit_import_data() so that we only call munmap() once. We have two error paths here, one where we have an fd to close and one where we do not. Adjust labels to match this. Reported-by: Coverity (CID: 167366, 167367, 167370) Signed-off-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/gpt.c2
-rw-r--r--cmd/nvedit.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/cmd/gpt.c b/cmd/gpt.c
index 9e04affc06..27dd98755a 100644
--- a/cmd/gpt.c
+++ b/cmd/gpt.c
@@ -402,7 +402,7 @@ static int set_gpt_info(struct blk_desc *dev_desc,
if (!val) {
#ifdef CONFIG_RANDOM_UUID
*str_disk_guid = malloc(UUID_STR_LEN + 1);
- if (str_disk_guid == NULL)
+ if (*str_disk_guid == NULL)
return -ENOMEM;
gen_rand_uuid_str(*str_disk_guid, UUID_STR_FORMAT_STD);
#else
diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index 8752ff475a..90f76bbc20 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -393,7 +393,7 @@ int do_env_ask(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
sprintf(message, "Please enter '%s': ", argv[1]);
} else {
/* env_ask envname message1 ... messagen [size] */
- for (i = 2, pos = 0; i < argc && pos < sizeof(message); i++) {
+ for (i = 2, pos = 0; i < argc && pos+1 < sizeof(message); i++) {
if (pos)
message[pos++] = ' ';