Do not read past the end of fmt_desc[]
authorBart Van Assche <bvanassche@acm.org>
Sun, 24 May 2020 03:39:47 +0000 (20:39 -0700)
committerBart Van Assche <bvanassche@acm.org>
Sun, 24 May 2020 03:46:42 +0000 (20:46 -0700)
commit969b9fbbf4fadbe48eb4d9fea071837d2d3eeb11
tree8d89252d657dc2608d96f8a6e3ff5bf6832a9cbc
parent26f14c3162309115c87ed49fd4082e8cc27545d6
Do not read past the end of fmt_desc[]

Callers of parse_format() pass a size in bytes while the parse_format()
function itself expects a number of elements. Fix this by making the
fmt_desc[] array NULL-terminated. This patch fixes the following Coverity
complaint:

CID 300986 (#1 of 1): Out-of-bounds access (OVERRUN)
overrun-buffer-arg: Overrunning array fmt_desc of 1 24-byte elements by
passing it to a function which accesses it at element index 23 (byte
offset 575) using argument 24U.

Cc: Roman Pen <r.peniaev@gmail.com>
Fixes: 634bd210c17a ("lib/pattern: add set of functions to parse combined pattern input")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
lib/pattern.c
lib/pattern.h
options.c