From 4e7756e4deccf2f779061c6dccd7cc410fe25fb6 Mon Sep 17 00:00:00 2001 From: batrick Date: Sun, 4 Mar 2012 07:26:16 +0000 Subject: [PATCH] Change hostname parameter to const char *. --- nse_nmaplib.cc | 6 +----- tcpip.cc | 2 +- tcpip.h | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/nse_nmaplib.cc b/nse_nmaplib.cc index f09483821..949c60a32 100644 --- a/nse_nmaplib.cc +++ b/nse_nmaplib.cc @@ -742,13 +742,9 @@ static int l_resolve(lua_State *L) struct sockaddr_storage ss; struct addrinfo *addr, *addrs; int i; - char *host; + const char *host = luaL_checkstring(L, 1); int af = fams[luaL_checkoption(L, 2, "unspec", fam_op)]; - if (!lua_isstring(L, 1)) - luaL_error(L, "Host to resolve must be a string"); - host = (char *) lua_tostring(L, 1); - addrs = resolve_all(host, af); if (!addrs) { diff --git a/tcpip.cc b/tcpip.cc index 18118e978..57abcdb8b 100644 --- a/tcpip.cc +++ b/tcpip.cc @@ -437,7 +437,7 @@ const char *inet_socktop(struct sockaddr_storage *ss) { This function calls getaddrinfo and returns the same addrinfo linked list that getaddrinfo produces. Returns NULL for any error or failure to resolve. You need to call freeaddrinfo on the result if non-NULL. */ -struct addrinfo *resolve_all(char *hostname, int pf) +struct addrinfo *resolve_all(const char *hostname, int pf) { struct addrinfo hints; struct addrinfo *result; diff --git a/tcpip.h b/tcpip.h index a7049a80e..f40ed175f 100644 --- a/tcpip.h +++ b/tcpip.h @@ -264,7 +264,7 @@ const char *inet_socktop(struct sockaddr_storage *ss); structure. This function calls getaddrinfo and returns the same addrinfo linked list that getaddrinfo produces. Returns NULL for any error or failure to resolve. */ -struct addrinfo *resolve_all(char *hostname, int pf); +struct addrinfo *resolve_all(const char *hostname, int pf); /* Takes a destination address (dst) and tries to determine the source address and interface necessary to route to this address.