From 217e4b40d410f1ecedf4bdb412d6b514a98c1eee Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Tue, 16 Mar 2010 10:48:14 -0700 Subject: [PATCH] Check for callback argument in DNS functions --- src/node_dns.cc | 5 +++++ test/disabled/test-dns.js | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/src/node_dns.cc b/src/node_dns.cc index d26913d96d..8bb440a258 100644 --- a/src/node_dns.cc +++ b/src/node_dns.cc @@ -332,6 +332,11 @@ static Handle ResolveA(int type, const Arguments& args) { String::New("Argument must be a string."))); } + if (!args[1]->IsFunction()) { + return ThrowException(Exception::Error( + String::New("Missing callback argument"))); + } + String::Utf8Value name(args[0]->ToString()); struct dns_query *query; diff --git a/test/disabled/test-dns.js b/test/disabled/test-dns.js index 53bd23604f..7985728d22 100644 --- a/test/disabled/test-dns.js +++ b/test/disabled/test-dns.js @@ -3,6 +3,14 @@ require("../common"); var dns = require("dns"), sys = require("sys"); + +// Try resolution without callback + +assert.throws(function () { + dns.resolve('google.com', 'A'); +}) + + var hosts = ['example.com', 'example.org', 'ietf.org', // AAAA 'google.com', // MX, multiple A records