Skip to content

Commit 956283c

Browse files
authored
Merge commit from fork
rastertopclx.c: Fix infinite loop caused by crafted file
2 parents b103e2f + 0fe46c5 commit 956283c

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

filter/rastertopclx.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -825,10 +825,10 @@ StartPage(cf_filter_data_t *data, // I - filter data
825825
}
826826

827827
if (header->cupsCompression)
828-
CompBuffer = malloc(DotBufferSize * 4);
828+
CompBuffer = calloc(DotBufferSize * 4, sizeof(unsigned char));
829829

830830
if (header->cupsCompression >= 3)
831-
SeedBuffer = malloc(DotBufferSize);
831+
SeedBuffer = calloc(DotBufferSize, sizeof(unsigned char));
832832

833833
SeedInvalid = 1;
834834

@@ -1159,6 +1159,13 @@ CompressData(unsigned char *line, // I - Data to compress
11591159
seed ++;
11601160
count ++;
11611161
}
1162+
1163+
//
1164+
// Bail out if we don't have count to compress
1165+
//
1166+
1167+
if (count == 0)
1168+
break;
11621169
}
11631170

11641171
//
@@ -1252,6 +1259,13 @@ CompressData(unsigned char *line, // I - Data to compress
12521259

12531260
count = line_ptr - start;
12541261

1262+
//
1263+
// Bail out if we don't have count to compress
1264+
//
1265+
1266+
if (count == 0)
1267+
break;
1268+
12551269
#if 0
12561270
fprintf(stderr,
12571271
"DEBUG: offset=%d, count=%d, comp_ptr=%p(%d of %d)...\n",
@@ -1424,6 +1438,13 @@ CompressData(unsigned char *line, // I - Data to compress
14241438

14251439
count = (line_ptr - start) / 3;
14261440

1441+
//
1442+
// Bail out if we don't have count to compress
1443+
//
1444+
1445+
if (count == 0)
1446+
break;
1447+
14271448
//
14281449
// Place mode 10 compression data in the buffer; each sequence
14291450
// starts with a command byte that looks like:

0 commit comments

Comments
 (0)