1
0
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:
kris
2010-11-11 01:11:13 +00:00
parent 734f938b04
commit e39eeea8ba
3 changed files with 8 additions and 4 deletions

View File

@@ -260,7 +260,7 @@ usesock:
ret = send_ip_packet(udata->sock, NULL, (u8 *) packet, lua_objlen(L, 2)); ret = send_ip_packet(udata->sock, NULL, (u8 *) packet, lua_objlen(L, 2));
} }
if (ret == -1) 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()); socket_strerror(socket_errno()), socket_errno());
return success(L); return success(L);

View File

@@ -1,4 +1,5 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h>
#include "Target.h" #include "Target.h"
#include "portlist.h" #include "portlist.h"
@@ -57,10 +58,13 @@ int success (lua_State *L)
return 1; 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_pushboolean(L, false);
lua_pushstring(L, message); va_start(va, fmt);
lua_pushvfstring(L, fmt, va);
va_end(va);
return 2; return 2;
} }

View File

@@ -8,7 +8,7 @@ void setbfield (lua_State *, int, const char *, int);
void weak_table (lua_State *, int, int, const char *); void weak_table (lua_State *, int, int, const char *);
int success (lua_State *); 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 **); void check_target (lua_State *, int, const char **, const char **);
unsigned short check_port (lua_State *, int, const char **); unsigned short check_port (lua_State *, int, const char **);