From 86cfd1ada7b922d86b716774e4f8902d9cc8c95c Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 8 Apr 2020 15:22:35 -0400 Subject: relocate() return -1 on NULL arguments --- lib/relocation.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'lib/relocation.c') 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); -- cgit