diff options
author | Neal H. Walfield <[email protected]> | 2015-08-21 07:47:57 +0000 |
---|---|---|
committer | Neal H. Walfield <[email protected]> | 2015-08-21 12:21:04 +0000 |
commit | b3226cadf9bbef4a367072396e5b0abf37afff2d (patch) | |
tree | e6f5afbe90a22ac348adbebb4b69e00e56cb9a0f | |
parent | common: Check parameters more rigorously. (diff) | |
download | gnupg-b3226cadf9bbef4a367072396e5b0abf37afff2d.tar.gz gnupg-b3226cadf9bbef4a367072396e5b0abf37afff2d.zip |
common: Don't incorrectly copy packets with partial lengths.
* g10/parse-packet.c (parse): We don't handle copying packets with a
partial body length to an output stream. If this occurs, log an error
and abort.
--
Signed-off-by: Neal H. Walfield <[email protected]>.
-rw-r--r-- | g10/parse-packet.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/g10/parse-packet.c b/g10/parse-packet.c index 6f44efade..1467dc32a 100644 --- a/g10/parse-packet.c +++ b/g10/parse-packet.c @@ -654,6 +654,17 @@ parse (IOBUF inp, PACKET * pkt, int onlykeypkts, off_t * retpos, if (out && pkttype) { + /* This type of copying won't work if the packet uses a partial + body length. (In other words, this only works if HDR is + actually the length.) Currently, no callers require this + functionality so we just log this as an error. */ + if (partial) + { + log_error ("parse: Can't copy partial packet. Aborting.\n"); + rc = gpg_error (GPG_ERR_INV_PACKET); + goto leave; + } + rc = iobuf_write (out, hdr, hdrlen); if (!rc) rc = copy_packet (inp, out, pkttype, pktlen, partial); |