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:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user