]> granicus.if.org Git - graphviz/commitdiff
smyrna smyrnaPath: replace 'sprintf' calls with 'snprintf'
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 14 Jan 2023 23:20:22 +0000 (15:20 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 15 Jan 2023 17:51:07 +0000 (09:51 -0800)
Gitlab: #1950

cmd/smyrna/main.c

index 3edf9ab1d8d501c1068f40b50207f180ce2318c4..af6216198213aa490f135ece4f16c76b732c0803 100644 (file)
@@ -79,9 +79,9 @@ char *smyrnaPath(char *suffix)
     if (baselen == 0) {
        baselen = strlen(smyrnaDir) + 2;
     }
-    size_t slen = strlen(suffix);
-    char *buf = gv_calloc(baselen + slen, sizeof(char));
-    sprintf(buf, "%s%s%s", smyrnaDir, pathSep, suffix);
+    size_t len = baselen + strlen(suffix);
+    char *buf = gv_calloc(len, sizeof(char));
+    snprintf(buf, len, "%s%s%s", smyrnaDir, pathSep, suffix);
     return buf;
 }