Fossil SCM

In url_parse_local(), refuse a port number above 65535 as soon as it is read, so that a long run of digits cannot overflow.

dmestas 2026-11-18 21:20 UTC small-fixes
Commit 909ec71cdb6fbfc61462fec45984ef3f73e864010b10482e42caa71b923ccb1f
1 file changed +1
+1
--- src/url.c
+++ src/url.c
@@ -235,10 +235,11 @@
235235
if( c==':' ){
236236
pUrlData->port = 0;
237237
i++;
238238
while( (c = zUrl[i])!=0 && fossil_isdigit(c) ){
239239
pUrlData->port = pUrlData->port*10 + c - '0';
240
+ if( pUrlData->port>65535 ) fossil_fatal("port number too large in url");
240241
i++;
241242
}
242243
if( c!=0 && c!='/' && c!='?' && c!='#' ){
243244
fossil_fatal("url missing '/' after port number");
244245
}
245246
--- src/url.c
+++ src/url.c
@@ -235,10 +235,11 @@
235 if( c==':' ){
236 pUrlData->port = 0;
237 i++;
238 while( (c = zUrl[i])!=0 && fossil_isdigit(c) ){
239 pUrlData->port = pUrlData->port*10 + c - '0';
 
240 i++;
241 }
242 if( c!=0 && c!='/' && c!='?' && c!='#' ){
243 fossil_fatal("url missing '/' after port number");
244 }
245
--- src/url.c
+++ src/url.c
@@ -235,10 +235,11 @@
235 if( c==':' ){
236 pUrlData->port = 0;
237 i++;
238 while( (c = zUrl[i])!=0 && fossil_isdigit(c) ){
239 pUrlData->port = pUrlData->port*10 + c - '0';
240 if( pUrlData->port>65535 ) fossil_fatal("port number too large in url");
241 i++;
242 }
243 if( c!=0 && c!='/' && c!='?' && c!='#' ){
244 fossil_fatal("url missing '/' after port number");
245 }
246

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button