]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
http: fix Basic auth with empty name field in URL
authorDaniel Stenberg <daniel@haxx.se>
Wed, 6 Oct 2021 13:40:53 +0000 (15:40 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 6 Oct 2021 20:45:52 +0000 (22:45 +0200)
Add test 367 to verify.

Reported-by: Rick Lane
Fixes #7819
Closes #7820

lib/http.c
tests/data/Makefile.inc
tests/data/test367 [new file with mode: 0644]

index 648583c56ab40df592479f17b32282fda398a0a0..fe3f3a27b0e1c9a211c7ab0f3dd4803f0a5d1340 100644 (file)
@@ -323,7 +323,7 @@ static CURLcode http_output_basic(struct Curl_easy *data, bool proxy)
     pwd = data->state.aptr.passwd;
   }
 
-  out = aprintf("%s:%s", user, pwd ? pwd : "");
+  out = aprintf("%s:%s", user ? user : "", pwd ? pwd : "");
   if(!out)
     return CURLE_OUT_OF_MEMORY;
 
index 57f2abf69fa47574e6089c5bf9a6b8f6823ae2ff..1085e7bf04a636dbf98e5181c8488ef83a6c9be5 100644 (file)
@@ -60,7 +60,7 @@ test325 test326 test327 test328 test329 test330 test331 test332 test333 \
 test334 test335 test336 test337 test338 test339 test340 test341 test342 \
 test343 test344 test345 test346 test347 test348 test349 test350 test351 \
 test352 test353 test354 test355 test356 test357 test358 test359 test360 \
-test361 test362 test363 test364 test365 test366 \
+test361 test362 test363 test364 test365 test366 test367 \
 \
 test392 test393 test394 test395 test396 test397 \
 \
diff --git a/tests/data/test367 b/tests/data/test367
new file mode 100644 (file)
index 0000000..de8b901
--- /dev/null
@@ -0,0 +1,48 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP GET
+Basic
+</keywords>
+</info>
+
+#
+# Server-side
+<reply>
+<data>
+HTTP/1.1 200 OK
+Content-Length: 6
+Connection: close
+
+-foo-
+</data>
+</reply>
+
+#
+# Client-side
+<client>
+<server>
+http
+</server>
+<name>
+Empty user name provided in URL
+</name>
+<command>
+http://:example@%HOSTIP:%HTTPPORT/%TESTNUMBER
+</command>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<protocol>
+GET /%TESTNUMBER HTTP/1.1\r
+Host: %HOSTIP:%HTTPPORT\r
+Authorization: Basic OmV4YW1wbGU=\r
+User-Agent: curl/%VERSION\r
+Accept: */*\r
+\r
+</protocol>
+</verify>
+</testcase>