diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-04-10 13:11:42 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-04-10 13:11:42 -0400 |
| commit | ba555a8aca47a78acb173780fd252b19d3cdd36e (patch) | |
| tree | 3148daec492f359908a14fa0521bec227c4c8dc3 /src/stdlib | |
| parent | 0779052876689700d8df8e62ba66ef791dc841fa (diff) | |
Remove strlcpy()
Diffstat (limited to 'src/stdlib')
| -rw-r--r-- | src/stdlib/paths.c | 6 |
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) |
