Skip to content

Commit

Permalink
connection: check for transaction before attempts to access objects i…
Browse files Browse the repository at this point in the history
…n it

so Haraka doesn't crash
  • Loading branch information
msimerson committed Apr 8, 2014
1 parent 5f5fa3b commit 38253f9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions connection.js
Expand Up @@ -851,6 +851,10 @@ Connection.prototype.rset_respond = function(retval, msg) {

Connection.prototype.mail_respond = function(retval, msg) {
var self = this;
if (!this.transaction) {
this.logerror("mail_respond found no transaction!");
return;
}
var sender = this.transaction.mail_from;
var dmsg = "sender " + sender.format();
this.lognotice(dmsg + ' ' + [
Expand Down Expand Up @@ -885,6 +889,10 @@ Connection.prototype.mail_respond = function(retval, msg) {

Connection.prototype.rcpt_ok_respond = function (retval, msg) {
var self = this;
if (!this.transaction) {
this.logerror("rcpt_ok_respond found no transaction!");
return;
}
var rcpt = this.transaction.rcpt_to[this.transaction.rcpt_to.length - 1];
var dmsg = "recipient " + rcpt.format();
this.lognotice(dmsg + ' ' + [
Expand Down Expand Up @@ -935,6 +943,10 @@ Connection.prototype.rcpt_respond = function(retval, msg) {
}

var self = this;
if (!this.transaction) {
this.logerror("rcpt_respond found no transaction!");
return;
}
var rcpt = this.transaction.rcpt_to[this.transaction.rcpt_to.length - 1];
var dmsg = "recipient " + rcpt.format();
if (retval !== constants.ok) {
Expand Down

0 comments on commit 38253f9

Please sign in to comment.