From: Kevin Day Date: Thu, 9 May 2024 01:50:50 +0000 (-0500) Subject: Security: Potential buffer overflow on 0 length array. X-Git-Tag: 0.6.10~4 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=1f6925c208d70c0bca0b6c3588d032addc79a5c4;p=fll Security: Potential buffer overflow on 0 length array. The length_name_item variable can potentially be zero. The assignment of "name_item[length_name_item] = 0;" will then result in an assignment on a 0 length array. This issue has been exposed via GCC's -fanalyzer. --- diff --git a/level_3/controller/c/rule/private-rule.c b/level_3/controller/c/rule/private-rule.c index a0c2428..94829cd 100644 --- a/level_3/controller/c/rule/private-rule.c +++ b/level_3/controller/c/rule/private-rule.c @@ -3971,7 +3971,7 @@ extern "C" { const f_array_length_t line_item = cache->action.line_item; const f_array_length_t length_name_item = cache->action.name_item.used; - f_char_t name_item[length_name_item]; + f_char_t name_item[length_name_item + 1]; name_item[length_name_item] = 0; memcpy(name_item, cache->action.name_item.string, sizeof(f_char_t) * length_name_item);