mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-08 12:44:23 +01:00
common: Avoid undefined behavior.
* common/iobuf.c (iobuf_read_line): Do not consider 'length' if 'buffer' is NULL. Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
parent
a6142dbdbc
commit
214fa90122
@ -2552,7 +2552,7 @@ iobuf_read_line (iobuf_t a, byte ** addr_of_buffer,
|
|||||||
NUL character in the buffer. This requires at least 2 bytes. We
|
NUL character in the buffer. This requires at least 2 bytes. We
|
||||||
don't complicate the code by handling the stupid corner case, but
|
don't complicate the code by handling the stupid corner case, but
|
||||||
simply assert that it can't happen. */
|
simply assert that it can't happen. */
|
||||||
assert (length >= 2 || maxlen >= 2);
|
assert (!buffer || length >= 2 || maxlen >= 2);
|
||||||
|
|
||||||
if (!buffer || length <= 1)
|
if (!buffer || length <= 1)
|
||||||
/* must allocate a new buffer */
|
/* must allocate a new buffer */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user