aboutsummaryrefslogtreecommitdiff
path: root/cmd/bcb.c
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/bcb.c')
-rw-r--r--cmd/bcb.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/cmd/bcb.c b/cmd/bcb.c
index 5da3526..6b6f1e9 100644
--- a/cmd/bcb.c
+++ b/cmd/bcb.c
@@ -11,6 +11,7 @@
#include <common.h>
#include <log.h>
#include <part.h>
+#include <malloc.h>
enum bcb_cmd {
BCB_CMD_LOAD,
@@ -179,10 +180,10 @@ static int do_bcb_load(struct cmd_tbl *cmdtp, int flag, int argc,
return __bcb_load(devnum, argv[2]);
}
-static int __bcb_set(char *fieldp, char *valp)
+static int __bcb_set(char *fieldp, const char *valp)
{
int size, len;
- char *field, *str, *found;
+ char *field, *str, *found, *tmp;
if (bcb_field_get(fieldp, &field, &size))
return CMD_RET_FAILURE;
@@ -193,14 +194,20 @@ static int __bcb_set(char *fieldp, char *valp)
valp, len, size, fieldp);
return CMD_RET_FAILURE;
}
- str = valp;
+ str = strdup(valp);
+ if (!str) {
+ printf("Error: Out of memory while strdup\n");
+ return CMD_RET_FAILURE;
+ }
+ tmp = str;
field[0] = '\0';
- while ((found = strsep(&str, ":"))) {
+ while ((found = strsep(&tmp, ":"))) {
if (field[0] != '\0')
strcat(field, "\n");
strcat(field, found);
}
+ free(str);
return CMD_RET_SUCCESS;
}
@@ -308,7 +315,7 @@ static int do_bcb_store(struct cmd_tbl *cmdtp, int flag, int argc,
return __bcb_store();
}
-int bcb_write_reboot_reason(int devnum, char *partp, char *reasonp)
+int bcb_write_reboot_reason(int devnum, char *partp, const char *reasonp)
{
int ret;