Skip to content

Commit afbf725

Browse files
remicolletsmalyshev
authored andcommitted
Fix bug #68601 buffer read overflow in gd_gif_in.c
1 parent caecd88 commit afbf725

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? 2015 PHP 5.4.40
44

5+
- GD:
6+
. Fixed bug #68601 (buffer read overflow in gd_gif_in.c). (Remi)
7+
58
- SOAP:
69
. Fixed bug #69152 (Type Confusion Infoleak Vulnerability in unserialize()
710
with SoapFault). (Dmitry)

ext/gd/libgd/gd_gif_in.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,10 @@ static struct {
7272

7373
#define STACK_SIZE ((1<<(MAX_LWZ_BITS))*2)
7474

75+
#define CSD_BUF_SIZE 280
76+
7577
typedef struct {
76-
unsigned char buf[280];
78+
unsigned char buf[CSD_BUF_SIZE];
7779
int curbit, lastbit, done, last_byte;
7880
} CODE_STATIC_DATA;
7981

@@ -400,7 +402,12 @@ GetCode_(gdIOCtx *fd, CODE_STATIC_DATA *scd, int code_size, int flag, int *ZeroD
400402

401403
ret = 0;
402404
for (i = scd->curbit, j = 0; j < code_size; ++i, ++j)
403-
ret |= ((scd->buf[ i / 8 ] & (1 << (i % 8))) != 0) << j;
405+
if (i < CSD_BUF_SIZE * 8) {
406+
ret |= ((scd->buf[i / 8] & (1 << (i % 8))) != 0) << j;
407+
} else {
408+
ret = -1;
409+
break;
410+
}
404411

405412
scd->curbit += code_size;
406413
return ret;

0 commit comments

Comments
 (0)