~ubuntu-branches/ubuntu/hardy/gnupg2/hardy

« back to all changes in this revision

Viewing changes to g10/parse-packet.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2006-08-16 10:43:10 UTC
  • Revision ID: james.westby@ubuntu.com-20060816104310-qrac5j4k4je1nrpg
Tags: 1.9.21-0ubuntu5
* SECURITY UPDATE: Local arbitrary code execution.
* Fix buffer overflows in parse_comment() and parse_gpg_control().
* Reproducer: perl -e 'print "\xfd\xff\xff\xff\xff\xfe"'| gpg --no-armor
* CVE-2006-3746

Show diffs side-by-side

added added

removed removed

Lines of Context:
2119
2119
{
2120
2120
    byte *p;
2121
2121
 
 
2122
    /* Cap comment packet at a reasonable value to avoid an integer
 
2123
       overflow in the malloc below.  Comment packets are actually not
 
2124
       anymore define my OpenPGP and we even stopped to use our
 
2125
       private comment packet. */
 
2126
    if (pktlen>65536)
 
2127
      {
 
2128
       log_error ("packet(%d) too large\n", pkttype);
 
2129
        iobuf_skip_rest(inp, pktlen, 0);
 
2130
       return GPG_ERR_INV_PACKET;
 
2131
      }
 
2132
 
2122
2133
    packet->pkt.comment = xmalloc(sizeof *packet->pkt.comment + pktlen - 1);
2123
2134
    packet->pkt.comment->len = pktlen;
2124
2135
    p = packet->pkt.comment->data;
2361
2372
    size_t sesmarklen;
2362
2373
    int i;
2363
2374
 
 
2375
    /* Definitely too large.  We skip it to avoid an overflow in the malloc. */
 
2376
    if (pktlen > 4096)
 
2377
        goto skipit;
 
2378
 
2364
2379
    if ( list_mode )
2365
2380
        fprintf (listfp, ":packet 63: length %lu ",  pktlen);
2366
2381