Fix issue detected by static analysis tool 38/295938/2
authorJihoon Kim <jihoon48.kim@samsung.com>
Mon, 17 Jul 2023 11:02:21 +0000 (20:02 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Tue, 18 Jul 2023 02:23:06 +0000 (11:23 +0900)
Because sprintf assumes an arbitrarily long string,
callers must be careful not to overflow the actual space of the destination.

Change-Id: I4a3e641459d1da0f54db7eeb109447868906e394
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
src/compose/parser.c

index f84b314..36a0c85 100644 (file)
@@ -652,7 +652,7 @@ rhs:
             scanner_warn(s, "right-hand side string is too long; skipping line");
             goto skip;
         }
-        strcpy(production.string, val.string.str);
+        strncpy(production.string, val.string.str, sizeof(production.string)-1);
         production.has_string = true;
         goto rhs;
     case TOK_IDENT: