diff options
Diffstat (limited to 'lib/path.c')
| -rw-r--r-- | lib/path.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/path.c b/lib/path.c index 1a623bc6d6..eaa6d881c6 100644 --- a/lib/path.c +++ b/lib/path.c @@ -244,12 +244,18 @@ path_read_cpulist(int maxcpus, const char *path, ...) return set; } -void +int path_set_prefix(const char *prefix) { - prefixlen = strlen(prefix); - strncpy(pathbuf, prefix, sizeof(pathbuf)); - pathbuf[sizeof(pathbuf) - 1] = '\0'; + size_t len = strlen(prefix); + + if (len >= sizeof(pathbuf) - 1) { + errno = ENAMETOOLONG; + return -1; + } + prefixlen = len; + strcpy(pathbuf, prefix); + return 0; } #endif /* HAVE_CPU_SET_T */ |
