aboutsummaryrefslogtreecommitdiff
path: root/lib/strlist.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/strlist.c')
-rw-r--r--lib/strlist.c11
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) {