From: Victor Julien Date: Fri, 17 Apr 2020 13:00:40 +0000 (+0200) Subject: conf/datadir: fix possible out of bounds array access X-Git-Tag: suricata-6.0.0-beta1~491 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0ce489bcc9629b7b4cc5a29288df318d2d5472a6;p=thirdparty%2Fsuricata.git conf/datadir: fix possible out of bounds array access --- diff --git a/src/util-conf.c b/src/util-conf.c index f36bfbf088..a5fc0e2c95 100644 --- a/src/util-conf.c +++ b/src/util-conf.c @@ -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;