]> git.ipfire.org Git - thirdparty/bind9.git/commit
Fix a logical bug in cfg_print_duration()
authorAram Sargsyan <aram@isc.org>
Mon, 17 Oct 2022 08:45:09 +0000 (08:45 +0000)
committerAram Sargsyan <aram@isc.org>
Mon, 17 Oct 2022 08:52:20 +0000 (08:52 +0000)
commitb6978ccbe310e39b7d578d54d17c5fecf404f18d
treeb840b44564b7185f00240429bae48f0f19584751
parente33fdd5c053e0df64329a1e5cafec65baae221ff
Fix a logical bug in cfg_print_duration()

The cfg_print_duration() function prints a ISO 8601 duration value
converted from an array of integers, where the parts of the date and
time are stored.

durationlen[6], which holds the "seconds" part of the duration, has
a special case in cfg_print_duration() to ensure that when there are
no values in the duration, the result still can be printed as "PT0S",
instead of just "P", so it can be a valid ISO 8601 duration value.

There is a logical error in one of the two special case code paths,
when it checks that no value from the "date" part is defined, and no
"hour" or "minute" from the "time" part are defined.

Because of the error, durationlen[6] can be used uninitialized, in
which case the second parameter passed to snprintf() (which is the
maximum allowed length) can contain a garbage value.

This can not be exploited because the buffer is still big enough to
hold the maximum possible amount of characters generated by the "%u%c"
format string.

Fix the logical bug, and initialize the 'durationlen' array to zeros
to be a little safer from other similar errors.

(cherry picked from commit 94409101870b689f77452b6324968687d9f3c72f)
lib/isccfg/parser.c