1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-25 17:09:02 +00:00

Adding Snprintf() and Vsnprintf() to nbase/nbase_str.c. This is because of Windows' stupid implementation where it doesn't write a NULL byte at the end of the buffer if the result is truncated. I would've just #defined snprintf and vsnprintf to some wrapper function for Windows, but this doesn't work as libdnet and libpcap (and libpcap includes under mswin32) define snprintf to _snprintf and vsnprintf to _vsnprintf like we do, and through the many defines they end up being available in the Nmap sources. Vsnprintf() uses vsnprintf() (and writes a NULL byte at the end if truncated), and Snprintf uses Vsnprintf().

This commit is contained in:
kris
2007-08-14 06:46:54 +00:00
parent 9f41f69d1b
commit 0b50c16b38
23 changed files with 174 additions and 176 deletions

View File

@@ -20,6 +20,7 @@ extern "C" {
#include <locale.h>
#include <pcre.h>
#include "nbase.h"
#include "pcre.h"
static void L_lua_error(lua_State *L, const char *message)
@@ -50,11 +51,11 @@ static int udata_tostring (lua_State *L, const char* type_handle,
void *udata = luaL_checkudata(L, 1, type_handle);
if(udata) {
(void)snprintf(buf, 255, "%s (%p)", type_name, udata);
(void)Snprintf(buf, 255, "%s (%p)", type_name, udata);
lua_pushstring(L, buf);
}
else {
(void)snprintf(buf, 255, "must be userdata of type '%s'", type_name);
(void)Snprintf(buf, 255, "must be userdata of type '%s'", type_name);
(void)luaL_argerror(L, 1, buf);
}
@@ -140,7 +141,7 @@ static int Lpcre_comp(lua_State *L)
ud->pr = pcre_compile(pattern, cflags, &error, &erroffset, tables);
if(!ud->pr) {
(void)snprintf(buf, 255, "%s (pattern offset: %d)", error, erroffset+1);
(void)Snprintf(buf, 255, "%s (pattern offset: %d)", error, erroffset+1);
/* show offset 1-based as it's common in Lua */
L_lua_error(L, buf);
}