iniparser: Fix CID 241908 Copy into fixed size buffer
authorVolker Lendecke <vl@samba.org>
Sat, 9 Nov 2013 19:37:01 +0000 (20:37 +0100)
committerIra Cooper <ira@samba.org>
Mon, 11 Nov 2013 20:04:08 +0000 (21:04 +0100)
strcpy is never a good idea....

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ira Cooper <ira@samba.org>
lib/iniparser/src/iniparser.c

index 09340876d8c85b45106bdffec3f9cc0d9973fcbf..db00c88e7adac51034da0115fe57cff7629753ba 100644 (file)
@@ -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 ;
 }