From 726496b1711117d113b8da971edf8114db07ab06 Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Wed, 10 Jul 2019 23:02:12 +0100 Subject: Include the file extension when checking for log filename length. --- logging.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'logging.c') diff --git a/logging.c b/logging.c index 6e8d9b7..c3271fe 100644 --- a/logging.c +++ b/logging.c @@ -84,8 +84,8 @@ int logline(char *str, char *ournick, char *basedir, int type) { // Remove unsafe characters (assuming POSIX, just strip "/" and replace with "_") replacechar(from, '/', '_'); replacechar(to, '/', '_'); - // Ensure filename wouldn't be too long - if (strlen(from) > NAME_MAX || strlen(to) > NAME_MAX) { + // Ensure filename wouldn't be too long (+ 4 for ".log") + if (strlen(from) + 4 > NAME_MAX || strlen(to) + 4 > NAME_MAX) { debugprint(DEBUG_CRIT, "Filename would be too long if logging either '%s' or '%s', returning!\n", from, to); return 0; } -- cgit v1.2.3