]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tool_getparam: error out on missing -K file
authorDaniel Stenberg <daniel@haxx.se>
Mon, 25 Apr 2022 09:38:37 +0000 (11:38 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 25 Apr 2022 09:38:50 +0000 (11:38 +0200)
Add test 411 to verify.

Reported-by: Median Median Stride
Bug: https://hackerone.com/reports/1542881
Closes #8731

src/tool_getparam.c
tests/data/Makefile.inc
tests/data/test411 [new file with mode: 0644]

index 52a247d27aa5bb70e4d7d6e4e5ee2064190ad9ef..67de74dff7cbf8d0051d78d480a1681de4212b0b 100644 (file)
@@ -1948,9 +1948,10 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
         config->insecure_ok = toggle;
       break;
     case 'K': /* parse config file */
-      if(parseconfig(nextarg, global))
-        warnf(global, "error trying read config from the '%s' file\n",
-              nextarg);
+      if(parseconfig(nextarg, global)) {
+        errorf(global, "cannot read config from '%s'\n", nextarg);
+        return PARAM_READ_ERROR;
+      }
       break;
     case 'l':
       config->dirlistonly = toggle; /* only list the names of the FTP dir */
index 7e9b6b4fb717f629c4c3ace283dba98f52a07b78..76910f98fd3a429eefb341d79b807ed6abd92aac 100644 (file)
@@ -68,7 +68,7 @@ test380 test381 test383 test384 test385 test386 \
 test392 test393 test394 test395 test396 test397 test398 \
 \
 test400 test401 test402 test403 test404 test405 test406 test407 test408 \
-test409 test410 \
+test409 test410 test411 \
 \
 test430 test431 test432 test433 test434 test435 test436 \
 \
diff --git a/tests/data/test411 b/tests/data/test411
new file mode 100644 (file)
index 0000000..912f07c
--- /dev/null
@@ -0,0 +1,43 @@
+<testcase>
+<info>
+<keywords>
+-K
+</keywords>
+</info>
+
+#
+# Server-side
+<reply>
+</reply>
+
+#
+# Client-side
+<client>
+<server>
+none
+</server>
+ <name>
+-K with missing file causes error
+ </name>
+ <command>
+-K log/missing http://localhost
+</command>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<stderr mode="text">
+curl: cannot read config from 'log/missing'
+curl: option -K: error encountered when reading a file
+%if manual
+curl: try 'curl --help' or 'curl --manual' for more information
+%else
+curl: try 'curl --help' for more information
+%endif
+</stderr>
+<errorcode>
+26
+</errorcode>
+</verify>
+</testcase>