From ba555a8aca47a78acb173780fd252b19d3cdd36e Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 10 Apr 2025 13:11:42 -0400 Subject: Remove strlcpy() --- src/stdlib/paths.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/stdlib/paths.c b/src/stdlib/paths.c index cad0e0ff..04c6f7ee 100644 --- a/src/stdlib/paths.c +++ b/src/stdlib/paths.c @@ -527,7 +527,8 @@ public Path_t Path$unique_directory(Path_t path) size_t len = strlen(path_str); if (len >= PATH_MAX) fail("Path is too long: ", path_str); char buf[PATH_MAX] = {}; - strlcpy(buf, path_str, sizeof(buf)); + memcpy(buf, path_str, len); + buf[len] = '\0'; if (buf[len-1] == '/') buf[--len] = '\0'; char *created = mkdtemp(buf); @@ -542,7 +543,8 @@ public Path_t Path$write_unique_bytes(Path_t path, List_t bytes) size_t len = strlen(path_str); if (len >= PATH_MAX) fail("Path is too long: ", path_str); char buf[PATH_MAX] = {}; - strlcpy(buf, path_str, sizeof(buf)); + memcpy(buf, path_str, len); + buf[len] = '\0'; // Count the number of trailing characters leading up to the last "X" // (e.g. "foo_XXXXXX.tmp" would yield suffixlen = 4) -- cgit v1.2.3