git: 72c3d91294c4 - stable/14 - libfetch: parse scheme://domain:/ correctly

From: Ka Ho Ng <khng_at_FreeBSD.org>
Date: Wed, 03 Apr 2024 19:12:16 UTC
The branch stable/14 has been updated by khng:

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

commit 72c3d91294c4d9c46c8185f90cba522f539d1051
Author:     Ka Ho Ng <khng@FreeBSD.org>
AuthorDate: 2024-03-25 20:10:42 +0000
Commit:     Ka Ho Ng <khng@FreeBSD.org>
CommitDate: 2024-04-03 19:11:58 +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
    
    (cherry picked from commit fb860ed0c52c2c1e7792ef86718620a439663c7f)
---
 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 135ee8dad151..8cb3536a46c5 100644
--- a/lib/libfetch/fetch.c
+++ b/lib/libfetch/fetch.c
@@ -427,7 +427,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;