summaryrefslogtreecommitdiff
path: root/application/boottable
diff options
context:
space:
mode:
authorJérome Lefranc2009-01-23 00:15:01 +0100
committerJérome Lefranc2009-01-23 00:15:01 +0100
commit139a28e5e162f6e4d0b91b542cfa8ffea51948fb (patch)
treea43532fb80b8f61fc907b1715567b249836d7bd2 /application/boottable
parent4bf68e68a9383873eaa1cb0b902ab026cf60ad56 (diff)
[bt] fix bug #219 'bt rename does not check name length'
Diffstat (limited to 'application/boottable')
-rwxr-xr-xapplication/boottable/src/commands_linux.c5
-rw-r--r--application/boottable/src/image_table_linux.c5
2 files changed, 6 insertions, 4 deletions
diff --git a/application/boottable/src/commands_linux.c b/application/boottable/src/commands_linux.c
index 228ddb5f80..61850f0769 100755
--- a/application/boottable/src/commands_linux.c
+++ b/application/boottable/src/commands_linux.c
@@ -597,15 +597,16 @@ int rename_active_image()
struct plc_system plcSystem;
/* char date[]=__DATE__;*/
char *ptr;
+ memset(runningImg, '\0', 64);
/* test if running image is "active" */
if (get_running_entry_name(runningImg))
return -1;
/* if running image name is active, then rename it to current software release */
- if (strcmp(runningImg,"active")==0) {
+ if (strncmp(runningImg,"active", 6)==0) {
mib_getPlcSystem(&plcSystem);
- strcpy(runningImg,plcSystem.softwareVersion);
+ strncpy(runningImg,plcSystem.softwareVersion, 63);
#if 0
ptr = strtok(date," ");
while (ptr != NULL) {
diff --git a/application/boottable/src/image_table_linux.c b/application/boottable/src/image_table_linux.c
index 6ebae578fb..b5c2547304 100644
--- a/application/boottable/src/image_table_linux.c
+++ b/application/boottable/src/image_table_linux.c
@@ -463,7 +463,8 @@ int rename_entry(const char *oldName, const char *newName)
char temp[ENTRY_NAME_LEN];
int iteration=0;
- strncpy(name,newName,ENTRY_NAME_LEN - IT_SZ);
+ memset(name, '\0', ENTRY_NAME_LEN);
+ strncpy(name,newName,ENTRY_NAME_LEN - IT_SZ);
//Btable not setup return
if (!entry_table_setup)
@@ -482,7 +483,7 @@ int rename_entry(const char *oldName, const char *newName)
//Find entry name
while ((idx = find_index_by_name(name, &ctx.entry))>=0) {
sprintf(temp,"-%d",iteration++);
- strncpy(name,newName,ENTRY_NAME_LEN - IT_SZ);
+ strncpy(name,newName,ENTRY_NAME_LEN - IT_SZ - 1);
strncat(name,temp,IT_SZ);
}
//Rename it