[Skiboot] [PATCH 2/8] queue_led_state_change() - Fix unterminated string warning

Kamalesh Babulal kamalesh at linux.vnet.ibm.com
Tue Jun 23 18:37:32 AEST 2015


struct led_set_cmd cmd is zalloc. While doing strncpy of
loc_code to cmd->loc_code, there are chances of cmd->loc_code
being unterminated. Fix the issue by copying LOC_CODE_SIZE - 1.

Fixes Coverity defect #100249.

Signed-off-by: Kamalesh Babulal <kamalesh at linux.vnet.ibm.com>
Cc: Ananth N Mavinakayanahalli <ananth at in.ibm.com>
Cc: Vasant Hegde <hegdevasant at linux.vnet.ibm.com>
---
 hw/fsp/fsp-leds.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/fsp/fsp-leds.c b/hw/fsp/fsp-leds.c
index 82be37a..877aca1 100644
--- a/hw/fsp/fsp-leds.c
+++ b/hw/fsp/fsp-leds.c
@@ -683,7 +683,7 @@ static int queue_led_state_change(char *loc_code, u8 command,
 	}
 
 	/* Save the request */
-	strncpy(cmd->loc_code, loc_code, LOC_CODE_SIZE);
+	strncpy(cmd->loc_code, loc_code, LOC_CODE_SIZE - 1);
 	cmd->command = command;
 	cmd->state = state;
 	cmd->cmd_src = cmd_src;
-- 
2.1.2



More information about the Skiboot mailing list