mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 01:48:00 +00:00
When checking for an existing log, store the FILE * in a local variable.
It's not used outside logfopen, and leaving an infalid file pointer lying around in the log context caused a segfault if the user cancelled logging. Bug found by afl-fuzz before it had even started fuzzing.
This commit is contained in:
parent
e170041a5d
commit
c445c745ec
@ -164,6 +164,7 @@ void logfopen(void *handle)
|
|||||||
{
|
{
|
||||||
struct LogContext *ctx = (struct LogContext *)handle;
|
struct LogContext *ctx = (struct LogContext *)handle;
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
|
FILE *fp;
|
||||||
int mode;
|
int mode;
|
||||||
|
|
||||||
/* Prevent repeat calls */
|
/* Prevent repeat calls */
|
||||||
@ -183,10 +184,10 @@ void logfopen(void *handle)
|
|||||||
conf_get_str(ctx->conf, CONF_host),
|
conf_get_str(ctx->conf, CONF_host),
|
||||||
conf_get_int(ctx->conf, CONF_port), &tm);
|
conf_get_int(ctx->conf, CONF_port), &tm);
|
||||||
|
|
||||||
ctx->lgfp = f_open(ctx->currlogfilename, "r", FALSE); /* file already present? */
|
fp = f_open(ctx->currlogfilename, "r", FALSE); /* file already present? */
|
||||||
if (ctx->lgfp) {
|
if (fp) {
|
||||||
int logxfovr = conf_get_int(ctx->conf, CONF_logxfovr);
|
int logxfovr = conf_get_int(ctx->conf, CONF_logxfovr);
|
||||||
fclose(ctx->lgfp);
|
fclose(fp);
|
||||||
if (logxfovr != LGXF_ASK) {
|
if (logxfovr != LGXF_ASK) {
|
||||||
mode = ((logxfovr == LGXF_OVR) ? 2 : 1);
|
mode = ((logxfovr == LGXF_OVR) ? 2 : 1);
|
||||||
} else
|
} else
|
||||||
|
Loading…
Reference in New Issue
Block a user