Fossil SCM
On the /errorlog page, do not call fclose() on a NULL pointer when the error log cannot be opened for truncation.
Commit
43462be3a5135016ecec9a2842bbd20da57d64dc6b5acd5f36b42aebb01f46da
Parent
c1b050255c1419a…
1 file changed
+2
-1
+2
-1
| --- src/security_audit.c | ||
| +++ src/security_audit.c | ||
| @@ -897,11 +897,12 @@ | ||
| 897 | 897 | no_error_log_available(); |
| 898 | 898 | style_finish_page(); |
| 899 | 899 | return; |
| 900 | 900 | } |
| 901 | 901 | 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); | |
| 903 | 904 | } |
| 904 | 905 | if( P("download") ){ |
| 905 | 906 | Blob log; |
| 906 | 907 | blob_read_from_file(&log, g.zErrlog, ExtFILE); |
| 907 | 908 | cgi_set_content_type("text/plain"); |
| 908 | 909 |
| --- 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 |