common: Fix iobuf_peek corner case.
authorJustus Winter <justus@g10code.com>
Tue, 26 Jul 2016 16:29:01 +0000 (18:29 +0200)
committerJustus Winter <justus@g10code.com>
Tue, 26 Jul 2016 16:37:37 +0000 (18:37 +0200)
commitb2572b0c386fd12ac6581fcce72f8d48cbfd27c7
tree562942c29a59deae8c35a79079562d8d9022ca9c
parent046338b8494c036a5e717130d3eadce0291126fc
common: Fix iobuf_peek corner case.

Previously, iobuf_peek on a file smaller than 'buflen' would hang.

* common/iobuf.c (underflow): Generalize by adding a target parameter.
(iobuf_peek): Use this to prevent looping here.
* tests/openpgp/Makefile.am (TESTS): Add new test.
* tests/openpgp/setup.scm (dearmor): Move function...
* tests/openpgp/defs.scm (dearmor): ... here.
* tests/openpgp/issue2419.scm: New file.
* tests/openpgp/samplemsgs/issue2419.asc: Likewise.

GnuPG-bug-id: 2419
Signed-off-by: Justus Winter <justus@g10code.com>
common/iobuf.c
tests/openpgp/Makefile.am
tests/openpgp/defs.scm
tests/openpgp/issue2419.scm [new file with mode: 0755]
tests/openpgp/samplemsgs/issue2419.asc [new file with mode: 0644]
tests/openpgp/setup.scm