From 76dd72ba94b10800c397a94ec08d91cc545cbfb3 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 4 Sep 2008 14:36:48 +0000 Subject: [PATCH] Add a guard against getaddrinfo returning an empty list of addresses in l_nsock_connect. It hasn't been reported to cause problems but will cause a crash if it ever happens. --- nse_nsock.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nse_nsock.cc b/nse_nsock.cc index 37496cff7..484580017 100644 --- a/nse_nsock.cc +++ b/nse_nsock.cc @@ -451,6 +451,11 @@ static int l_nsock_connect(lua_State *L) { lua_pushstring(L, error); return 2; } + if (dest == NULL) { + lua_pushboolean(L, false); + lua_pushstring(L, "getaddrinfo returned success but no addresses"); + return 2; + } udata->nsiod = nsi_new(nsp, NULL); if (o.spoofsource) {