From a584261feffe4db0a2736105d838d795ca524f44 Mon Sep 17 00:00:00 2001 From: Gilles Chehade Date: Wed, 6 Jul 2011 20:56:17 +0000 Subject: fix that fscking "fgetln(): bad file descriptor" bug experienced by many. long story short: datafp is reused by the possibly multiple client sessions of a MTA session. fclosing it in client_close() will cause the file pointer to be invalidated as soon as we fail the primary MX and attempt the second. bug introduced while trying to fix a leak causing a crash for a user, now smtpd will unconditionnally fclose() in MTA_DONE and if a leak still exists then we should track why the mta session doesnt reach MTA_DONE. --- usr.sbin/smtpd/client.c | 3 +-- usr.sbin/smtpd/mta.c | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'usr.sbin/smtpd') diff --git a/usr.sbin/smtpd/client.c b/usr.sbin/smtpd/client.c index a1fd25a2a18..00979d279e1 100644 --- a/usr.sbin/smtpd/client.c +++ b/usr.sbin/smtpd/client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.36 2011/05/14 11:06:32 gilles Exp $ */ +/* $OpenBSD: client.c,v 1.37 2011/07/06 20:56:16 gilles Exp $ */ /* * Copyright (c) 2009 Jacek Masiulaniec @@ -572,7 +572,6 @@ client_close(struct smtp_client *sp) SSL_free(sp->ssl); #endif close(sp->w.fd); - fclose(sp->body); free(sp); } diff --git a/usr.sbin/smtpd/mta.c b/usr.sbin/smtpd/mta.c index 96d0fda7627..b5cf1ddb1de 100644 --- a/usr.sbin/smtpd/mta.c +++ b/usr.sbin/smtpd/mta.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mta.c,v 1.107 2011/05/21 18:39:03 gilles Exp $ */ +/* $OpenBSD: mta.c,v 1.108 2011/07/06 20:56:16 gilles Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard @@ -511,8 +511,7 @@ mta_enter_state(struct mta_session *s, int newstate, void *p) free(relay); } - if (s->datafp) - fclose(s->datafp); + fclose(s->datafp); free(s->secret); free(s->host); -- cgit v1.2.3