haraka / Haraka

A fast, highly extensible, and event driven SMTP server
https://haraka.github.io
MIT License
5.02k stars 662 forks source link

connect.fcrdns crash bug #664

Closed msimerson closed 10 years ago

msimerson commented 10 years ago

Aug 30 15:50:10 filter1-mail haraka[51667]: [CRIT] [-] [core] TypeError: Cannot call method 'split' of null Aug 30 15:50:10 filter1-mail haraka[51667]: [CRIT] [-] [core] at asyncCallback (dns.js:68:16) Aug 30 15:50:10 filter1-mail haraka[51667]: [CRIT] [-] [core] at Object.onanswer as oncomplete Aug 30 15:50:10 filter1-mail haraka[51667]: [CRIT] [-] [core] at /usr/local/lib/node_modules/Haraka/plugins/connect.fcrdns.js:101:31 Aug 30 15:50:10 filter1-mail node[51667]: [CRIT] [-] [core] at Plugin.exports.is_generic_rdns (/usr/local/lib/node_modules/Haraka/plugins/connect.fcrdns.js:265:54) Aug 30 15:50:10 filter1-mail node[51667]: [CRIT] [-] [core] at Plugin.exports.check_fcrdns (/usr/local/lib/node_modules/Haraka/plugins/connect.fcrdns.js:195:20)

msimerson commented 10 years ago

Interestingly enough, at the top of the method in which this code runs is this:

exports.is_generic_rdns = function (connection, domain) {
      var plugin = this;
      if (!domain) return false;

Which made me think that this would be safe:

var host_part = domain.split('.').slice(0,orgDom.split('.').length+1);  

But apparently I was wrong.

msimerson commented 10 years ago

Ahah, and the first split is safe, but the second one is not.