diff options
author | Ananth N Mavinakayanahalli <ananth@in.ibm.com> | 2015-06-16 21:20:20 +0530 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2015-06-19 10:17:24 +1000 |
commit | 2c4e9eedd427c0a29c999ffd1b4ec07f1fae7ee5 (patch) | |
tree | 3c972782e6be4bfdf5570d8a5062c5fbdd36ec19 /hw | |
parent | f2f04830b08a3be7d7fb4af1e412e69d3caa5377 (diff) | |
download | skiboot-2c4e9eedd427c0a29c999ffd1b4ec07f1fae7ee5.zip skiboot-2c4e9eedd427c0a29c999ffd1b4ec07f1fae7ee5.tar.gz skiboot-2c4e9eedd427c0a29c999ffd1b4ec07f1fae7ee5.tar.bz2 |
Fix possible buffer overflow
NULL terminate and truncate size of copy into char buffer to the right size.
Signed-off-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/fsp/fsp-console.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/hw/fsp/fsp-console.c b/hw/fsp/fsp-console.c index c1195f2..2a25e1c 100644 --- a/hw/fsp/fsp-console.c +++ b/hw/fsp/fsp-console.c @@ -511,7 +511,8 @@ static void fsp_serial_add(int index, u16 rsrc_id, const char *loc_code, } ser->rsrc_id = rsrc_id; - strncpy(ser->loc_code, loc_code, LOC_CODE_SIZE); + memset(ser->loc_code, 0x00, LOC_CODE_SIZE); + strncpy(ser->loc_code, loc_code, LOC_CODE_SIZE - 1); ser->available = true; ser->log_port = log_port; unlock(&fsp_con_lock); |