Fossil SCM

Fix a possible "use-after-free" while rendering a [/help?cmd=/file|/file] page for the case when "ci" parameter is missing. This is a preliminary fix, it may introduce a (tiny) memory leak.

george 2021-06-19 02:29 trunk
Commit a6477bca6540cde677543c7a41a6b3b40a8ba1231d5ee14bc35623c3b7162693
1 file changed +3 -2
+3 -2
--- src/info.c
+++ src/info.c
@@ -2339,11 +2339,11 @@
23392339
return;
23402340
}
23412341
23422342
url_initialize(&url, g.zPath);
23432343
url_add_parameter(&url, "name", zName);
2344
- url_add_parameter(&url, "ci", zCI);
2344
+ url_add_parameter(&url, "ci", zCI); /* no-op if zCI is NULL */
23452345
23462346
if( zCI==0 && !isFile ){
23472347
/* If there is no ci= query parameter, then prefer to interpret
23482348
** name= as a hash for /artifact and /whatis. But for not for /file.
23492349
** For /file, a name= without a ci= while prefer to use the default
@@ -2381,11 +2381,12 @@
23812381
" ORDER BY event.mtime DESC",
23822382
zName
23832383
);
23842384
if( db_step(&q)==SQLITE_ROW ){
23852385
rid = db_column_int(&q, 0);
2386
- zCI = zCIUuid = fossil_strdup(db_column_text(&q, 1));
2386
+ zCI = fossil_strdup(db_column_text(&q, 1));
2387
+ zCIUuid = fossil_strdup(zCI);
23872388
url_add_parameter(&url, "ci", zCI);
23882389
}
23892390
db_finalize(&q);
23902391
if( rid==0 ){
23912392
style_header("No such file");
23922393
--- src/info.c
+++ src/info.c
@@ -2339,11 +2339,11 @@
2339 return;
2340 }
2341
2342 url_initialize(&url, g.zPath);
2343 url_add_parameter(&url, "name", zName);
2344 url_add_parameter(&url, "ci", zCI);
2345
2346 if( zCI==0 && !isFile ){
2347 /* If there is no ci= query parameter, then prefer to interpret
2348 ** name= as a hash for /artifact and /whatis. But for not for /file.
2349 ** For /file, a name= without a ci= while prefer to use the default
@@ -2381,11 +2381,12 @@
2381 " ORDER BY event.mtime DESC",
2382 zName
2383 );
2384 if( db_step(&q)==SQLITE_ROW ){
2385 rid = db_column_int(&q, 0);
2386 zCI = zCIUuid = fossil_strdup(db_column_text(&q, 1));
 
2387 url_add_parameter(&url, "ci", zCI);
2388 }
2389 db_finalize(&q);
2390 if( rid==0 ){
2391 style_header("No such file");
2392
--- src/info.c
+++ src/info.c
@@ -2339,11 +2339,11 @@
2339 return;
2340 }
2341
2342 url_initialize(&url, g.zPath);
2343 url_add_parameter(&url, "name", zName);
2344 url_add_parameter(&url, "ci", zCI); /* no-op if zCI is NULL */
2345
2346 if( zCI==0 && !isFile ){
2347 /* If there is no ci= query parameter, then prefer to interpret
2348 ** name= as a hash for /artifact and /whatis. But for not for /file.
2349 ** For /file, a name= without a ci= while prefer to use the default
@@ -2381,11 +2381,12 @@
2381 " ORDER BY event.mtime DESC",
2382 zName
2383 );
2384 if( db_step(&q)==SQLITE_ROW ){
2385 rid = db_column_int(&q, 0);
2386 zCI = fossil_strdup(db_column_text(&q, 1));
2387 zCIUuid = fossil_strdup(zCI);
2388 url_add_parameter(&url, "ci", zCI);
2389 }
2390 db_finalize(&q);
2391 if( rid==0 ){
2392 style_header("No such file");
2393

Keyboard Shortcuts

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