g10: Fix undefined behavior when EOF in parsing packet for S2K.
authorNIIBE Yutaka <gniibe@fsij.org>
Fri, 10 Aug 2018 06:29:06 +0000 (15:29 +0900)
committerNIIBE Yutaka <gniibe@fsij.org>
Fri, 10 Aug 2018 06:29:06 +0000 (15:29 +0900)
commit1b309d9f6199a91caa0ca0b97b92d599e00b736e
treecd1713dc5519c9279108c232226cc23a0199fc01
parente88f56f1937ac92f6a3b94e50b6db2649ec0be41
g10: Fix undefined behavior when EOF in parsing packet for S2K.

* g10/parse-packet.c (parse_symkeyenc): Use iobuf_get_noeof.
(parse_key): Likewise.

--

When EOF comes at parsing s2k.count, it is possible the value will
be (unsigned long)-1.  Then, the result of S2K_DECODE_COUNT will be
undefined.  This patch fixes undefined behavior.

Reported-by: Philippe Antoine
GnuPG-bug-id: 4093
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
g10/parse-packet.c