1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

Fix crashes when assigning timeouts as floats. New NSE utility function nseU_checkinteger

This commit is contained in:
dmiller
2016-07-17 04:56:29 +00:00
parent 62c4985536
commit dbc26606ca
3 changed files with 22 additions and 4 deletions

View File

@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <stdarg.h>
#include <math.h>
#include "Target.h"
#include "portlist.h"
@@ -7,6 +8,16 @@
#include "nse_main.h"
#include "nse_utility.h"
int nseU_checkinteger (lua_State *L, int arg)
{
lua_Number n = luaL_checknumber(L, arg);
int i;
if (!lua_numbertointeger(floor(n), &i)) {
return luaL_error(L, "Number cannot be converted to an integer");
}
return i;
}
int nseU_traceback (lua_State *L)
{
if (lua_isstring(L, 1))