1 From: Justus Winter <justus@g10code.com>
2 Date: Thu, 30 Mar 2017 15:44:35 +0200
3 Subject: common: Avoid undefined behavior.
5 * common/iobuf.c (iobuf_read_line): Do not consider 'length' if
8 Signed-off-by: Justus Winter <justus@g10code.com>
9 (cherry picked from commit 214fa9012296d796b78f1a3106d656639cf50aef)
12 1 file changed, 1 insertion(+), 1 deletion(-)
14 diff --git a/common/iobuf.c b/common/iobuf.c
15 index d346027..b8baf7f 100644
18 @@ -2552,7 +2552,7 @@ iobuf_read_line (iobuf_t a, byte ** addr_of_buffer,
19 NUL character in the buffer. This requires at least 2 bytes. We
20 don't complicate the code by handling the stupid corner case, but
21 simply assert that it can't happen. */
22 - assert (length >= 2 || maxlen >= 2);
23 + assert (!buffer || length >= 2 || maxlen >= 2);
25 if (!buffer || length <= 1)
26 /* must allocate a new buffer */