mirror of
https://github.com/nmap/nmap.git
synced 2025-12-20 14:39:02 +00:00
Since r20267 (NSE Nsock maintenance), failures in raw IP sends from NSE cause
scripts to bail. (This is why Ron saw a backtrace when path-mtu elicited an EMSGSIZE [a separate issue I'm still working on] instead of path-mtu recognizing the failure and resending with a smaller MTU like it would do before.) I'm changing this back to the original design of returning false to scripts (just like connect-mode send failures). I've changed safe_error() in nse_utility.cc to support varargs.
This commit is contained in:
@@ -260,7 +260,7 @@ usesock:
|
||||
ret = send_ip_packet(udata->sock, NULL, (u8 *) packet, lua_objlen(L, 2));
|
||||
}
|
||||
if (ret == -1)
|
||||
return luaL_error(L, "error while sending: %s (errno %d)",
|
||||
return safe_error(L, "error while sending: %s (errno %d)",
|
||||
socket_strerror(socket_errno()), socket_errno());
|
||||
|
||||
return success(L);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "Target.h"
|
||||
#include "portlist.h"
|
||||
@@ -57,10 +58,13 @@ int success (lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int safe_error (lua_State *L, const char *message)
|
||||
int safe_error (lua_State *L, const char *fmt, ...)
|
||||
{
|
||||
va_list va;
|
||||
lua_pushboolean(L, false);
|
||||
lua_pushstring(L, message);
|
||||
va_start(va, fmt);
|
||||
lua_pushvfstring(L, fmt, va);
|
||||
va_end(va);
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ void setbfield (lua_State *, int, const char *, int);
|
||||
void weak_table (lua_State *, int, int, const char *);
|
||||
|
||||
int success (lua_State *);
|
||||
int safe_error (lua_State *, const char *);
|
||||
int safe_error (lua_State *, const char *, ...);
|
||||
|
||||
void check_target (lua_State *, int, const char **, const char **);
|
||||
unsigned short check_port (lua_State *, int, const char **);
|
||||
|
||||
Reference in New Issue
Block a user