Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Fix harmless memory leaks. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
37ae94b365a9f32191b41862b989a9ac |
| User & Date: | drh 2024-12-18 11:39:56.135 |
Context
|
2024-12-18
| ||
| 12:51 | Fix additional harmless memory leaks. check-in: d564056cce user: drh tags: trunk | |
| 11:39 | Fix harmless memory leaks. check-in: 37ae94b365 user: drh tags: trunk | |
| 05:06 | Call `cgi_is_loopback()' before `db_open_local()' when checking for a local `fossil ui' session. The former performs simple string comparison, while the latter crawls the file system for multiple (3) check-out database file names at multiple directory hierarchy levels. The main motivation for this change is to reduce "attack surface" of the /jchunk interface, but also to align `cgi_is_loopback()' vs. `db_open_local()' precedence with usage elsewhere in the code base. check-in: 2dda151c40 user: florian tags: trunk | |
Changes
Changes to src/db.c.
| ︙ | ︙ | |||
2103 2104 2105 2106 2107 2108 2109 |
if( strcmp(blob_str(&bNameCheck), g.nameOfExe)==0 ){
extern int sqlite3_appendvfs_init(
sqlite3 *, char **, const sqlite3_api_routines *
);
sqlite3_appendvfs_init(0,0,0);
g.zVfsName = "apndvfs";
}
| | | 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 |
if( strcmp(blob_str(&bNameCheck), g.nameOfExe)==0 ){
extern int sqlite3_appendvfs_init(
sqlite3 *, char **, const sqlite3_api_routines *
);
sqlite3_appendvfs_init(0,0,0);
g.zVfsName = "apndvfs";
}
blob_reset(&bNameCheck);
rc = sqlite3_open_v2(
zDbName, &db,
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
g.zVfsName
);
if( rc!=SQLITE_OK ){
db_err("[%s]: %s", zDbName, sqlite3_errmsg(db));
|
| ︙ | ︙ |
Changes to src/doc.c.
| ︙ | ︙ | |||
786 787 788 789 790 791 792 |
const char *zDefaultTitle, /* Default title */
const char *zFilename /* Name of the file being rendered */
){
Blob title;
int isPopup = P("popup")!=0;
blob_init(&title,0,0);
if( fossil_strcmp(zMime, "text/x-fossil-wiki")==0 ){
| | > > | 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 |
const char *zDefaultTitle, /* Default title */
const char *zFilename /* Name of the file being rendered */
){
Blob title;
int isPopup = P("popup")!=0;
blob_init(&title,0,0);
if( fossil_strcmp(zMime, "text/x-fossil-wiki")==0 ){
Blob tail = BLOB_INITIALIZER;
style_adunit_config(ADUNIT_RIGHT_OK);
if( wiki_find_title(pBody, &title, &tail) ){
if( !isPopup ) style_header("%s", blob_str(&title));
wiki_convert(&tail, 0, WIKI_BUTTONS);
}else{
if( !isPopup ) style_header("%s", zDefaultTitle);
wiki_convert(pBody, 0, WIKI_BUTTONS);
}
if( !isPopup ){
document_emit_js();
style_finish_page();
}
blob_reset(&tail);
}else if( fossil_strcmp(zMime, "text/x-markdown")==0 ){
Blob tail = BLOB_INITIALIZER;
markdown_to_html(pBody, &title, &tail);
if( !isPopup ){
if( blob_size(&title)>0 ){
style_header("%s", blob_str(&title));
}else{
style_header("%s", zDefaultTitle);
}
}
convert_href_and_output(&tail);
if( !isPopup ){
document_emit_js();
style_finish_page();
}
blob_reset(&tail);
}else if( fossil_strcmp(zMime, "text/plain")==0 ){
style_header("%s", zDefaultTitle);
@ <blockquote><pre>
@ %h(blob_str(pBody))
@ </pre></blockquote>
document_emit_js();
style_finish_page();
|
| ︙ | ︙ | |||
947 948 949 950 951 952 953 954 955 956 957 958 959 960 |
#endif
};
login_check_credentials();
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
style_set_current_feature("doc");
blob_init(&title, 0, 0);
zDfltTitle = isUV ? "" : "Documentation";
db_begin_transaction();
while( rid==0 && (++nMiss)<=count(azSuffix) ){
zName = P("name");
if( isUV ){
if( zName==0 ) zName = "index.wiki";
i = 0;
| > | 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 |
#endif
};
login_check_credentials();
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
style_set_current_feature("doc");
blob_init(&title, 0, 0);
blob_init(&filebody, 0, 0);
zDfltTitle = isUV ? "" : "Documentation";
db_begin_transaction();
while( rid==0 && (++nMiss)<=count(azSuffix) ){
zName = P("name");
if( isUV ){
if( zName==0 ) zName = "index.wiki";
i = 0;
|
| ︙ | ︙ | |||
1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 |
Th_Store("doc_date", db_text(0, "SELECT datetime(mtime) FROM event"
" WHERE objid=%d AND type='ci'", vid));
}
cgi_check_for_malice();
document_render(&filebody, zMime, zDfltTitle, zName);
if( nMiss>=count(azSuffix) ) cgi_set_status(404, "Not Found");
db_end_transaction(0);
return;
/* Jump here when unable to locate the document */
doc_not_found:
db_end_transaction(0);
if( isUV && P("name")==0 ){
uvlist_page();
return;
}
cgi_set_status(404, "Not Found");
style_header("Not Found");
@ <p>Document %h(zOrigName) not found
if( fossil_strcmp(zCheckin,"ckout")!=0 ){
@ in %z(href("%R/tree?ci=%T",zCheckin))%h(zCheckin)</a>
}
style_finish_page();
return;
}
/*
** The default logo.
*/
static const unsigned char aLogo[] = {
| > > > > | 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 |
Th_Store("doc_date", db_text(0, "SELECT datetime(mtime) FROM event"
" WHERE objid=%d AND type='ci'", vid));
}
cgi_check_for_malice();
document_render(&filebody, zMime, zDfltTitle, zName);
if( nMiss>=count(azSuffix) ) cgi_set_status(404, "Not Found");
db_end_transaction(0);
blob_reset(&title);
blob_reset(&filebody);
return;
/* Jump here when unable to locate the document */
doc_not_found:
db_end_transaction(0);
if( isUV && P("name")==0 ){
uvlist_page();
return;
}
cgi_set_status(404, "Not Found");
style_header("Not Found");
@ <p>Document %h(zOrigName) not found
if( fossil_strcmp(zCheckin,"ckout")!=0 ){
@ in %z(href("%R/tree?ci=%T",zCheckin))%h(zCheckin)</a>
}
style_finish_page();
blob_reset(&title);
blob_reset(&filebody);
return;
}
/*
** The default logo.
*/
static const unsigned char aLogo[] = {
|
| ︙ | ︙ |
Changes to src/info.c.
| ︙ | ︙ | |||
318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
|TIMELINE_GRAPH
|TIMELINE_FILLGAPS
|TIMELINE_NOSCROLL
|TIMELINE_XMERGE
|TIMELINE_CHPICK,
0, 0, 0, rid, rid2, 0);
db_finalize(&q);
}
/*
** Append the difference between artifacts to the output
*/
static void append_diff(
| > | 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 |
|TIMELINE_GRAPH
|TIMELINE_FILLGAPS
|TIMELINE_NOSCROLL
|TIMELINE_XMERGE
|TIMELINE_CHPICK,
0, 0, 0, rid, rid2, 0);
db_finalize(&q);
blob_reset(&sql);
}
/*
** Append the difference between artifacts to the output
*/
static void append_diff(
|
| ︙ | ︙ |
Changes to src/style.c.
| ︙ | ︙ | |||
819 820 821 822 823 824 825 826 827 828 829 830 831 832 |
headerHasBeenGenerated = 1;
sideboxUsed = 0;
if( g.perm.Debug && P("showqp") ){
@ <div class="debug">
cgi_print_all(0, 0, 0);
@ </div>
}
}
#if INTERFACE
/* Allowed parameters for style_adunit() */
#define ADUNIT_OFF 0x0001 /* Do not allow ads on this page */
#define ADUNIT_RIGHT_OK 0x0002 /* Right-side vertical ads ok here */
#endif
| > | 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 |
headerHasBeenGenerated = 1;
sideboxUsed = 0;
if( g.perm.Debug && P("showqp") ){
@ <div class="debug">
cgi_print_all(0, 0, 0);
@ </div>
}
fossil_free(zTitle);
}
#if INTERFACE
/* Allowed parameters for style_adunit() */
#define ADUNIT_OFF 0x0001 /* Do not allow ads on this page */
#define ADUNIT_RIGHT_OK 0x0002 /* Right-side vertical ads ok here */
#endif
|
| ︙ | ︙ | |||
1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 |
*/
Th_Store("baseurl", g.zBaseURL);
Th_Store("secureurl", fossil_wants_https(1)? g.zHttpsURL: g.zBaseURL);
Th_Store("home", g.zTop);
image_url_var("logo");
image_url_var("background");
Th_Render(blob_str(&css));
/* Tell CGI that the content returned by this page is considered cacheable */
g.isConst = 1;
}
/*
** All possible capabilities
| > | 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 |
*/
Th_Store("baseurl", g.zBaseURL);
Th_Store("secureurl", fossil_wants_https(1)? g.zHttpsURL: g.zBaseURL);
Th_Store("home", g.zTop);
image_url_var("logo");
image_url_var("background");
Th_Render(blob_str(&css));
blob_reset(&css);
/* Tell CGI that the content returned by this page is considered cacheable */
g.isConst = 1;
}
/*
** All possible capabilities
|
| ︙ | ︙ |
Changes to src/timeline.c.
| ︙ | ︙ | |||
3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 |
selectedRid, secondaryRid, 0);
db_finalize(&q);
if( zOlderButton ){
@ %z(chref("button","%s",zOlderButton))%h(zOlderButtonLabel)\
@ ↓</a>
}
document_emit_js(/*handles pikchrs rendered above*/);
style_finish_page();
}
/*
** Translate a timeline entry into the printable format by
** converting every %-substitutions as follows:
**
| > > | 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 |
selectedRid, secondaryRid, 0);
db_finalize(&q);
if( zOlderButton ){
@ %z(chref("button","%s",zOlderButton))%h(zOlderButtonLabel)\
@ ↓</a>
}
document_emit_js(/*handles pikchrs rendered above*/);
blob_reset(&sql);
blob_reset(&desc);
style_finish_page();
}
/*
** Translate a timeline entry into the printable format by
** converting every %-substitutions as follows:
**
|
| ︙ | ︙ |