aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-04-10 13:11:42 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-04-10 13:11:42 -0400
commitba555a8aca47a78acb173780fd252b19d3cdd36e (patch)
tree3148daec492f359908a14fa0521bec227c4c8dc3 /src
parent0779052876689700d8df8e62ba66ef791dc841fa (diff)
Remove strlcpy()
Diffstat (limited to 'src')
-rw-r--r--src/stdlib/paths.c6
1 files 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)