gpg: Fix DoS while parsing mangled secret key packets.
authorWerner Koch <wk@gnupg.org>
Sun, 5 Apr 2015 17:33:36 +0000 (19:33 +0200)
committerWerner Koch <wk@gnupg.org>
Sun, 5 Apr 2015 17:33:36 +0000 (19:33 +0200)
commit0aac920f23fd07e152fdb7385299c92bb9a4ade3
tree53cb214e91a936a43f9a80ce6d2091d125cae16a
parent2a2da1b165f0a3050bca51dea67db9c04b9cb734
gpg: Fix DoS while parsing mangled secret key packets.

* g10/parse-packet.c (parse_key): Check PKTLEN before calling mpi_read
et al.
--

Due to the missing length checks PKTLEN may turn negative.  Because
PKTLEN is an unsigned int the malloc in read_rest would try to malloc
a too large number and terminate the process with "error reading rest
of packet: Cannot allocate memory".

Reported-by: Hanno Böck.
Signed-off-by: Werner Koch <wk@gnupg.org>
(backported from 2.1 commit d901efcebaefaf6eae4a9b9aa8f0c2c055d3518a)
g10/parse-packet.c