From: Pekka Riikonen Date: Tue, 18 Jun 2002 07:10:43 +0000 (+0000) Subject: check for correct length of debug string before copying it. X-Git-Tag: silc.client.0.9.2~9 X-Git-Url: http://git.silcnet.org/gitweb/?a=commitdiff_plain;h=00c2d14808f30847dde107c4af1a93aba23532c5;p=silc.git check for correct length of debug string before copying it. --- diff --git a/lib/silcutil/silclog.c b/lib/silcutil/silclog.c index dc74ace1..176c3eb7 100644 --- a/lib/silcutil/silclog.c +++ b/lib/silcutil/silclog.c @@ -488,11 +488,15 @@ void silc_log_reset_debug_callbacks() void silc_log_set_debug_string(const char *debug_string) { char *string; + int len; if ((strchr(debug_string, '(') && strchr(debug_string, ')')) || strchr(debug_string, '$')) string = strdup(debug_string); else string = silc_string_regexify(debug_string); - strncpy(silc_log_debug_string, string, strlen(string)); + len = strlen(string); + if (len >= sizeof(silc_log_debug_string)) + len = sizeof(silc_log_debug_string) - 1; + strncpy(silc_log_debug_string, string, len); silc_free(string); }