]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
conf/datadir: fix possible out of bounds array access
authorVictor Julien <victor@inliniac.net>
Fri, 17 Apr 2020 13:00:40 +0000 (15:00 +0200)
committerJeff Lucovsky <jeff@lucovsky.org>
Fri, 24 Apr 2020 14:06:26 +0000 (10:06 -0400)
(cherry picked from commit 0ce489bcc9629b7b4cc5a29288df318d2d5472a6)

src/util-conf.c

index c3fb07ea41a02b01f2b75e029c6e8693e98c5768..0afd47df7288578bd58f8d988fc06a685624256f 100644 (file)
@@ -74,7 +74,7 @@ TmEcode ConfigSetDataDirectory(char *name)
     size_t size = strlen(name) + 1;
     char tmp[size];
     strlcpy(tmp, name, size);
-    if (tmp[size - 2] == '/')
+    if (size > 2 && tmp[size - 2] == '/') // > 2 to allow just /
         tmp[size - 2] = '\0';
 
     return ConfSetFinal("default-data-dir", tmp) ? TM_ECODE_OK : TM_ECODE_FAILED;