check for correct length of debug string before copying it.
authorPekka Riikonen <priikone@silcnet.org>
Tue, 18 Jun 2002 07:10:43 +0000 (07:10 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Tue, 18 Jun 2002 07:10:43 +0000 (07:10 +0000)
lib/silcutil/silclog.c

index dc74ace1492e06ae4f3e13cb9e552389f60b6873..176c3eb73092be7156a56bf154af73a9e9868885 100644 (file)
@@ -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);
 }