1
0
mirror of https://github.com/nmap/nmap.git synced 2026-02-14 17:36:33 +00:00

Port numbers are integers; bugs happen when we use floats.

This commit is contained in:
dmiller
2016-08-30 18:59:54 +00:00
parent 3ea1cdf460
commit 610bb63f49
2 changed files with 6 additions and 6 deletions

View File

@@ -735,9 +735,9 @@ static int l_get_info (lua_State *L)
lua_pushboolean(L, true);
lua_pushstring(L, inet_ntop_both(af, &local, ipstring_local));
lua_pushnumber(L, inet_port_both(af, &local));
lua_pushinteger(L, inet_port_both(af, &local));
lua_pushstring(L, inet_ntop_both(af, &remote, ipstring_remote));
lua_pushnumber(L, inet_port_both(af, &remote));
lua_pushinteger(L, inet_port_both(af, &remote));
return 5;
}

View File

@@ -157,8 +157,8 @@ uint16_t nseU_checkport (lua_State *L, int idx, const char **protocol)
if (lua_istable(L, idx)) {
lua_getfield(L, idx, "number");
if (!lua_isnumber(L, -1))
luaL_argerror(L, idx, "port table lacks numeric 'number' field");
if (!lua_isinteger(L, -1))
luaL_argerror(L, idx, "port table lacks integer 'number' field");
port = (uint16_t) lua_tointeger(L, -1);
lua_getfield(L, idx, "protocol");
if (lua_isstring(L, -1))
@@ -205,8 +205,8 @@ Port *nseU_getport (lua_State *L, Target *target, Port *port, int idx)
idx = lua_absindex(L, idx);
luaL_checktype(L, idx, LUA_TTABLE);
lua_getfield(L, idx, "number");
if (!lua_isnumber(L, -1))
luaL_error(L, "port 'number' field must be a number");
if (!lua_isinteger(L, -1))
luaL_error(L, "port 'number' field must be an integer");
lua_getfield(L, idx, "protocol");
if (!lua_isstring(L, -1))
luaL_error(L, "port 'protocol' field must be a string");