Page MenuHome GnuPG

libksba: buffer overflow in append_ucs2_value()
Closed, ResolvedPublic

Description

In libksba, there is a buffer overflow on line 516 in append_ucs2_value() function:

503 c = *s++ << 8;
504 c |= *s++;
505 n += 2;
506 i=0;
507 if (c < (1<<11))
508 {
509 tmp[i++] = 0xc0 | ( c >> 6);
510 tmp[i++] = 0x80 | ( c & 0x3f);
511 }
512 else
513 {
514 tmp[i++] = 0xe0 | ( c >> 12);
515 tmp[i++] = 0x80 | ((c >> 6) & 0x3f);
516 tmp[i++] = 0x80 | ( c & 0x3f);
517 }
518 put_stringbuf_mem (sb, tmp, i);

The tmp buffer is declared as

467 unsigned char tmp[2];

I think the proper fix is to extend the tmp buffer to
be at least 3 chars long.

Details

Version
1.0.8

Event Timeline

ptr_uzl set Version to 1.0.8.
ptr_uzl added a subscriber: ptr_uzl.
werner claimed this task.

Good catch. Fixed in SVN. Thanks.