diff options
author | Samuel Mendoza-Jonas <sam.mj@au1.ibm.com> | 2015-11-09 14:59:41 +1100 |
---|---|---|
committer | Samuel Mendoza-Jonas <sam.mj@au1.ibm.com> | 2015-12-17 14:51:46 +1100 |
commit | df751aad6736c25a3f3088ad626bd28d2ced1991 (patch) | |
tree | d3d27e31dc85e2a6a5841a43025daf4ca7ea7e22 /discover/platform-powerpc.c | |
parent | eea8cf830616dbbd9024b7d704cf0ccf2dac4767 (diff) | |
download | petitboot-df751aad6736c25a3f3088ad626bd28d2ced1991.zip petitboot-df751aad6736c25a3f3088ad626bd28d2ced1991.tar.gz |
discover: Use snprintf() when building sysparam path
Fixes Coverity defects #30481 and #30482
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
Diffstat (limited to 'discover/platform-powerpc.c')
-rw-r--r-- | discover/platform-powerpc.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c index ce4eb81..2480b8d 100644 --- a/discover/platform-powerpc.c +++ b/discover/platform-powerpc.c @@ -759,9 +759,8 @@ static int read_bootdev_sysparam(const char *name, uint8_t *val) char path[50]; int fd, rc; - strcpy(path, sysparams_dir); - assert(strlen(name) < sizeof(path) - strlen(path)); - strcat(path, name); + assert(strlen(sysparams_dir) + strlen(name) < sizeof(path)); + snprintf(path, sizeof(path), "%s%s", sysparams_dir, name); fd = open(path, O_RDONLY); if (fd < 0) { @@ -795,9 +794,8 @@ static int write_bootdev_sysparam(const char *name, uint8_t val) char path[50]; int fd, rc; - strcpy(path, sysparams_dir); - assert(strlen(name) < sizeof(path) - strlen(path)); - strcat(path, name); + assert(strlen(sysparams_dir) + strlen(name) < sizeof(path)); + snprintf(path, sizeof(path), "%s%s", sysparams_dir, name); fd = open(path, O_WRONLY); if (fd < 0) { |