From 43ac7e81ec58d9043728b0e12b31f2993ec726c0 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 9 Nov 2013 20:37:01 +0100 Subject: [PATCH] iniparser: Fix CID 241908 Copy into fixed size buffer strcpy is never a good idea.... Signed-off-by: Volker Lendecke Reviewed-by: Ira Cooper --- lib/iniparser/src/iniparser.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/iniparser/src/iniparser.c b/lib/iniparser/src/iniparser.c index 09340876d8c..db00c88e7ad 100644 --- a/lib/iniparser/src/iniparser.c +++ b/lib/iniparser/src/iniparser.c @@ -38,16 +38,18 @@ static void iniparser_add_entry( char * val) { char longkey[2*ASCIILINESZ+1]; + char *l; /* Make a key as section:keyword */ if (key!=NULL) { - sprintf(longkey, "%s:%s", sec, key); + snprintf(longkey, sizeof(longkey), "%s:%s", sec, key); + l = longkey; } else { - strcpy(longkey, sec); + l = sec; } /* Add (key,val) to dictionary */ - dictionary_set(d, longkey, val); + dictionary_set(d, l, val); return ; }