summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2011-07-06 20:56:17 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2011-07-06 20:56:17 +0000
commita584261feffe4db0a2736105d838d795ca524f44 (patch)
tree33fd7d293ecfb0f596c9b8c6eaaf45c4ef3acb6e
parent71439565dc13acd0c12565c5ffe0070c15a31cb8 (diff)
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.
-rw-r--r--usr.sbin/smtpd/client.c3
-rw-r--r--usr.sbin/smtpd/mta.c5
2 files changed, 3 insertions, 5 deletions
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 <jacekm@dobremiasto.net>
@@ -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 <pyr@openbsd.org>
@@ -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);