diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2020-05-26 00:19:06 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2020-05-26 00:19:06 -0400 |
commit | 629ab111362a361729a8c2281c7168eb13729a77 (patch) | |
tree | fff565840eae2c90c02bd36fc9caf02cb689819b /lib/strlist.c | |
parent | ef427fa2c16139b2d6790b8867d5bdb6307fd14d (diff) | |
download | spmc-629ab111362a361729a8c2281c7168eb13729a77.tar.gz |
Make a copy of the path
Diffstat (limited to 'lib/strlist.c')
-rw-r--r-- | lib/strlist.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/strlist.c b/lib/strlist.c index c2cff09..0de0d2a 100644 --- a/lib/strlist.c +++ b/lib/strlist.c @@ -60,8 +60,9 @@ static int reader_strlist_append_file(size_t lineno, char **line) { * @param readerFn pointer to a reader function (use NULL to retrieve all data) * @return 0=success -1=error (spmerrno set) */ -int strlist_append_file(StrList *pStrList, char *path, ReaderFn *readerFn) { +int strlist_append_file(StrList *pStrList, char *_path, ReaderFn *readerFn) { int is_remote = 0; + char *path = NULL; char *filename = NULL; char *from_file_tmpdir = NULL; char **from_file = NULL; @@ -71,6 +72,12 @@ int strlist_append_file(StrList *pStrList, char *path, ReaderFn *readerFn) { readerFn = reader_strlist_append_file; } + path = strdup(_path); + if (path == NULL) { + spmerrno = errno; + return -1; + } + filename = calloc(PATH_MAX, sizeof(char)); if (filename == NULL) { spmerrno = errno; @@ -99,7 +106,7 @@ int strlist_append_file(StrList *pStrList, char *path, ReaderFn *readerFn) { return -1; } - strcpy(filename, fetched); + strncpy(filename, fetched, PATH_MAX - 1); } if (exists(filename) != 0) { |