diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2020-04-08 15:22:35 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2020-04-08 15:22:35 -0400 |
commit | 86cfd1ada7b922d86b716774e4f8902d9cc8c95c (patch) | |
tree | eae849600d2693a2b49f8845f7dd6910eabc3c36 /lib/relocation.c | |
parent | 3ff0e986bee05be4abb3c49d2fddec0fa8ccfc59 (diff) | |
download | spmc-86cfd1ada7b922d86b716774e4f8902d9cc8c95c.tar.gz |
relocate() return -1 on NULL arguments
Diffstat (limited to 'lib/relocation.c')
-rw-r--r-- | lib/relocation.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/relocation.c b/lib/relocation.c index 003b373..fa03aee 100644 --- a/lib/relocation.c +++ b/lib/relocation.c @@ -352,11 +352,18 @@ int prefixes_write(const char *output_file, int mode, char **prefix, const char int relocate(const char *_filename, const char *_oldstr, const char *_newstr) { int returncode; Process *proc = NULL; - char *oldstr = strdup(_oldstr); - char *newstr = strdup(_newstr); - char *filename = strdup(_filename); + char *filename = NULL; + char *oldstr = NULL; + char *newstr = NULL; char cmd[PATH_MAX]; + if (_filename == NULL || _oldstr == NULL || _newstr == NULL) { + return -1; + } + + oldstr = strdup(_oldstr); + newstr = strdup(_newstr); + filename = strdup(_filename); // sanitize command strchrdel(oldstr, SHELL_INVALID); strchrdel(newstr, SHELL_INVALID); |