git: fb860ed0c52c - main - libfetch: parse scheme://domain:/ correctly

From: Ka Ho Ng <khng_at_FreeBSD.org>
Date: Mon, 25 Mar 2024 20:14:26 UTC
The branch main has been updated by khng:

URL: https://cgit.FreeBSD.org/src/commit/?id=fb860ed0c52c2c1e7792ef86718620a439663c7f

commit fb860ed0c52c2c1e7792ef86718620a439663c7f
Author:     Ka Ho Ng <khng@FreeBSD.org>
AuthorDate: 2024-03-25 20:10:42 +0000
Commit:     Ka Ho Ng <khng@FreeBSD.org>
CommitDate: 2024-03-25 20:11:42 +0000

    libfetch: parse scheme://domain:/ correctly
    
    This improves URL-parsing compability with cURL, and unbreaks parsing of
    similar kinds of URLs after commit 8d9de5b10a24.
    
    Sponsored by:   Juniper Networks, Inc.
    Reviewed by:    des
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D44493
---
 lib/libfetch/fetch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/libfetch/fetch.c b/lib/libfetch/fetch.c
index 8fdcc8e8752e..df97bf486f9b 100644
--- a/lib/libfetch/fetch.c
+++ b/lib/libfetch/fetch.c
@@ -426,7 +426,7 @@ fetchParseURL(const char *URL)
 				goto ouch;
 			}
 		}
-		if (n < 1 || n > IPPORT_MAX)
+		if (p != q && (n < 1 || n > IPPORT_MAX))
 			goto ouch;
 		u->port = n;
 		p = q;