git: c89889b9c342 - stable/13 - libfetch: parse scheme://domain:/ correctly

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

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

commit c89889b9c342e764e39b351d5024a4ba3429fb15
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:12:38 +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;