aboutsummaryrefslogtreecommitdiff
path: root/lib/relocation.c
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@users.noreply.github.com>2020-04-09 01:29:16 -0400
committerGitHub <noreply@github.com>2020-04-09 01:29:16 -0400
commitd36652a97046e7c5a626cb39e39f83172a85ff3e (patch)
tree95c6d4ab4a864a1cb743d456467bb29003815cc5 /lib/relocation.c
parent3ff0e986bee05be4abb3c49d2fddec0fa8ccfc59 (diff)
parent7c3bb64c4d04c05724f6d0c48b3e065f693fdc1d (diff)
downloadspmc-d36652a97046e7c5a626cb39e39f83172a85ff3e.tar.gz
Merge pull request #15 from jhunkeler/test-relocate-relocate
Test relocate relocate
Diffstat (limited to 'lib/relocation.c')
-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);