[Skiboot] [PATCH 2/2] hdata: Fix location code size

Vasant Hegde hegdevasant at linux.vnet.ibm.com
Tue Mar 17 16:48:16 AEDT 2015


Location codes are no more than 80 characters (including
terminating NULL char).

Signed-off-by: Vasant Hegde <hegdevasant at linux.vnet.ibm.com>
---
 0 files changed

diff --git a/hdata/slca.c b/hdata/slca.c
index 9dd679e..aaa5fc6 100644
--- a/hdata/slca.c
+++ b/hdata/slca.c
@@ -79,13 +79,13 @@ const char *slca_get_loc_code_index(uint16_t slca_index)
 void slca_vpd_add_loc_code(struct dt_node *node, uint16_t slca_index)
 {
 	const char *fru_loc_code;
-	char loc_code[LOC_CODE_SIZE + 1];
+	char loc_code[LOC_CODE_SIZE];
 
 	memset(loc_code, 0, sizeof(loc_code));
 	fru_loc_code = slca_get_loc_code_index(slca_index);
 	if (!fru_loc_code)
 		return;
 
-	strncpy(loc_code, fru_loc_code, LOC_CODE_SIZE);
+	strncpy(loc_code, fru_loc_code, LOC_CODE_SIZE - 1);
 	dt_add_property(node, "ibm,loc-code", loc_code, strlen(loc_code) + 1);
 }



More information about the Skiboot mailing list