aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2020-04-08 15:22:35 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2020-04-08 15:22:35 -0400
commit86cfd1ada7b922d86b716774e4f8902d9cc8c95c (patch)
treeeae849600d2693a2b49f8845f7dd6910eabc3c36
parent3ff0e986bee05be4abb3c49d2fddec0fa8ccfc59 (diff)
downloadspmc-86cfd1ada7b922d86b716774e4f8902d9cc8c95c.tar.gz
relocate() return -1 on NULL arguments
-rw-r--r--lib/relocation.c13
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);