aboutsummaryrefslogtreecommitdiffstats
path: root/erts/etc/common/inet_gethost.c
diff options
context:
space:
mode:
authorMichael Santos <[email protected]>2010-04-12 20:22:03 -0400
committerBjörn Gustavsson <[email protected]>2010-05-03 13:46:38 +0200
commitd1b44cb27a59e45386f57e51f352dba0a3735a76 (patch)
treeb424396c5f75acbfdde5c50cb60b7d8ff7ec5387 /erts/etc/common/inet_gethost.c
parent3a68c36ca7aed71d643ea29460e36fec7e56817d (diff)
downloadotp-d1b44cb27a59e45386f57e51f352dba0a3735a76.tar.gz
otp-d1b44cb27a59e45386f57e51f352dba0a3735a76.tar.bz2
otp-d1b44cb27a59e45386f57e51f352dba0a3735a76.zip
Truncate debug messages
When the undocumented ERL_INET_GETHOST_DEBUG environment variable is set to 5, very long hostnames can overflow the buffer used to construct the debug message. Truncate debug messages if they exceed the size of the buffer. export ERL_INET_GETHOST_DEBUG=5 inet:gethostbyname(lists:duplicate(5000,"x")).
Diffstat (limited to 'erts/etc/common/inet_gethost.c')
-rw-r--r--erts/etc/common/inet_gethost.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/erts/etc/common/inet_gethost.c b/erts/etc/common/inet_gethost.c
index ff16ee02c4..bd2be4754b 100644
--- a/erts/etc/common/inet_gethost.c
+++ b/erts/etc/common/inet_gethost.c
@@ -52,6 +52,8 @@
# include "config.h"
#endif
+#include "erl_printf.h"
+
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
@@ -2552,7 +2554,7 @@ static void debugf(char *format, ...)
sprintf(buff,"%s[%d] (DEBUG):",program_name,(int) getpid());
#endif
ptr = buff + strlen(buff);
- vsprintf(ptr,format,ap);
+ erts_vsnprintf(ptr,sizeof(buff)-strlen(buff)-2,format,ap);
strcat(ptr,"\r\n");
#ifdef WIN32
if (debug_console_allocated != INVALID_HANDLE_VALUE) {
@@ -2574,7 +2576,7 @@ static void warning(char *format, ...)
va_start(ap,format);
sprintf(buff,"%s[%d]: WARNING:",program_name, (int) getpid());
ptr = buff + strlen(buff);
- vsprintf(ptr,format,ap);
+ erts_vsnprintf(ptr,sizeof(buff)-strlen(buff)-2,format,ap);
strcat(ptr,"\r\n");
#ifdef WIN32
{
@@ -2596,7 +2598,7 @@ static void fatal(char *format, ...)
va_start(ap,format);
sprintf(buff,"%s[%d]: FATAL ERROR:",program_name, (int) getpid());
ptr = buff + strlen(buff);
- vsprintf(ptr,format,ap);
+ erts_vsnprintf(ptr,sizeof(buff)-strlen(buff)-2,format,ap);
strcat(ptr,"\r\n");
#ifdef WIN32
{