]> granicus.if.org Git - graphviz/commitdiff
exsplit: fix missing NUL terminator append in GVPR splitting
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 16 Oct 2021 20:49:40 +0000 (13:49 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 19 Oct 2021 14:46:14 +0000 (07:46 -0700)
Commit 7ef9d53e2e6dc53c44939ace7a9cad57c3aa00bf refactored this code to avoid
the use of an SFIO buffer, inadvertently introducing a bug. The change did not
account for the source buffer not being NUL terminated. This fix wicks closer to
the original code, not assuming a NUL terminator and copying a known number of
bytes into the destination.

Related to #2138.

lib/expr/exeval.c

index d866db40d8670d8f3fa726fef238a822aa78d32d..c5abbf9e39f58b9169ed9d671d771a8aa860e989 100644 (file)
@@ -890,7 +890,8 @@ exsplit(Expr_t * ex, Exnode_t * expr, void *env)
                if (tok == NULL) {
                        tok = exnospace();
                } else {
-                       strncpy(tok, str, sz + 1);
+                       memcpy(tok, str, sz);
+                       tok[sz] = '\0';
                }
                addItem (arr, v, tok);
                v.integer++;