From 5fa944688dde4367658082bb01935a36113f7a2d Mon Sep 17 00:00:00 2001 From: Dmitry Mikhirev Date: Thu, 27 Nov 2014 14:08:53 +0300 Subject: safer message composing --- pcre.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pcre.c b/pcre.c index a17a08e..5630ac7 100644 --- a/pcre.c +++ b/pcre.c @@ -28,7 +28,7 @@ int plugin_is_GPL_compatible; const int MAX_CAP = 256; /* maximum number of substrings to capture */ const int MAX_CAP_LEN = 3; /* number of decimal digits in MAX_CAP */ -const int MAX_MSG_LEN = 1023; /* max length of error/warning/info message */ +const int MAX_MSG_LEN = 1024; /* max length of error/warning/info message */ /* esc_str() - escape string before assigning it to make variable */ char *esc_str(const char *str) @@ -63,8 +63,8 @@ int mk_error(const char *fmt, ...) va_start(args, fmt); - msg = gmk_alloc(MAX_MSG_LEN+1); - vsprintf(msg, fmt, args); + msg = gmk_alloc(MAX_MSG_LEN); + vsnprintf(msg, MAX_MSG_LEN, fmt, args); emsg = esc_str(msg); gmk_free(msg); mk = gmk_alloc(strlen(emsg) + 10); @@ -82,8 +82,8 @@ int mk_warning(const char *fmt, ...) va_start(args, fmt); - msg = gmk_alloc(MAX_MSG_LEN+1); - vsprintf(msg, fmt, args); + msg = gmk_alloc(MAX_MSG_LEN); + vsnprintf(msg, MAX_MSG_LEN, fmt, args); emsg = esc_str(msg); gmk_free(msg); mk = gmk_alloc(strlen(emsg) + 12); @@ -101,8 +101,8 @@ int mk_info(const char *fmt, ...) va_start(args, fmt); - msg = gmk_alloc(MAX_MSG_LEN+1); - vsprintf(msg, fmt, args); + msg = gmk_alloc(MAX_MSG_LEN); + vsnprintf(msg, MAX_MSG_LEN, fmt, args); emsg = esc_str(msg); gmk_free(msg); mk = gmk_alloc(strlen(emsg) + 9); -- cgit v1.2.1