Fossil SCM

On the /errorlog page, do not call fclose() on a NULL pointer when the error log cannot be opened for truncation.

dmestas 2026-11-12 04:04 UTC small-fixes
Commit 43462be3a5135016ecec9a2842bbd20da57d64dc6b5acd5f36b42aebb01f46da
1 file changed +2 -1
--- src/security_audit.c
+++ src/security_audit.c
@@ -897,11 +897,12 @@
897897
no_error_log_available();
898898
style_finish_page();
899899
return;
900900
}
901901
if( P("truncate1") && cgi_csrf_safe(2) ){
902
- fclose(fopen(g.zErrlog,"w"));
902
+ FILE *pLog = fopen(g.zErrlog,"w");
903
+ if( pLog ) fclose(pLog);
903904
}
904905
if( P("download") ){
905906
Blob log;
906907
blob_read_from_file(&log, g.zErrlog, ExtFILE);
907908
cgi_set_content_type("text/plain");
908909
--- src/security_audit.c
+++ src/security_audit.c
@@ -897,11 +897,12 @@
897 no_error_log_available();
898 style_finish_page();
899 return;
900 }
901 if( P("truncate1") && cgi_csrf_safe(2) ){
902 fclose(fopen(g.zErrlog,"w"));
 
903 }
904 if( P("download") ){
905 Blob log;
906 blob_read_from_file(&log, g.zErrlog, ExtFILE);
907 cgi_set_content_type("text/plain");
908
--- src/security_audit.c
+++ src/security_audit.c
@@ -897,11 +897,12 @@
897 no_error_log_available();
898 style_finish_page();
899 return;
900 }
901 if( P("truncate1") && cgi_csrf_safe(2) ){
902 FILE *pLog = fopen(g.zErrlog,"w");
903 if( pLog ) fclose(pLog);
904 }
905 if( P("download") ){
906 Blob log;
907 blob_read_from_file(&log, g.zErrlog, ExtFILE);
908 cgi_set_content_type("text/plain");
909

Keyboard Shortcuts

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