]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
curl: Fix segfault when -H @headerfile is empty
authorTobias Blomberg <sm0svx@users.noreply.github.com>
Thu, 26 Jul 2018 21:22:49 +0000 (23:22 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 28 Jul 2018 20:48:31 +0000 (22:48 +0200)
The curl binary would crash if the -H command line option was given a
filename to read using the @filename syntax but that file was empty.

Closes #2797

src/tool_getparam.c

index cc3fcf3a5705f3821692a9d20e1870db3bd6e5ca..e42a894cbae74dd13fbee89a671cb5405a1e2e0e 100644 (file)
@@ -1706,7 +1706,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
           warnf(global, "Failed to open %s!\n", &nextarg[1]);
         else {
           err = file2memory(&string, &len, file);
-          if(!err) {
+          if(!err && string) {
             /* Allow strtok() here since this isn't used threaded */
             /* !checksrc! disable BANNEDFUNC 2 */
             char *h = strtok(string, "\r\n");