Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1680)

Side by Side Diff: core/src/fxcodec/codec/fx_codec_flate.cpp

Issue 509993003: Restrict index not be greater than row_size in TIFF_PredictLine (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "../../fx_zlib.h" 7 #include "../../fx_zlib.h"
8 #include "../../../include/fxcodec/fx_codec.h" 8 #include "../../../include/fxcodec/fx_codec.h"
9 #include "codec_int.h" 9 #include "codec_int.h"
10 extern "C" 10 extern "C"
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 FX_LPBYTE scan_line = data_buf + row * row_size; 517 FX_LPBYTE scan_line = data_buf + row * row_size;
518 if ((row + 1) * row_size > (int)data_size) { 518 if ((row + 1) * row_size > (int)data_size) {
519 row_size = last_row_size; 519 row_size = last_row_size;
520 } 520 }
521 TIFF_PredictorEncodeLine(scan_line, row_size, BitsPerComponent, Colors, Columns); 521 TIFF_PredictorEncodeLine(scan_line, row_size, BitsPerComponent, Colors, Columns);
522 } 522 }
523 } 523 }
524 static void TIFF_PredictLine(FX_LPBYTE dest_buf, int row_size, int BitsPerCompon ent, int Colors, int Columns) 524 static void TIFF_PredictLine(FX_LPBYTE dest_buf, int row_size, int BitsPerCompon ent, int Colors, int Columns)
525 { 525 {
526 if (BitsPerComponent == 1) { 526 if (BitsPerComponent == 1) {
527 int row_bits = BitsPerComponent * Colors * Columns; 527 int row_bits = BitsPerComponent * Colors * Columns;
Tom Sepez 2014/08/27 21:25:45 nit: the multiply by 1 seems unnecessary.
Bo Xu 2014/08/27 22:13:18 Maybe we should keep it here to make the meaning m
528 for(int i = 1; i < row_bits; i ++) { 528 for(int i = 1; i < row_bits; i ++) {
529 int col = i % 8; 529 int col = i % 8;
530 int index = i / 8; 530 int index = i / 8;
531 if (index > row_size) {
Tom Sepez 2014/08/27 21:20:35 Don't you want >= ?
Tom Sepez 2014/08/27 21:25:45 Maybe we prune row_bits outside the loop to avoid
Bo Xu 2014/08/27 22:13:18 Good idea.
532 break;
533 }
531 int index_pre = (col == 0) ? (index - 1) : index; 534 int index_pre = (col == 0) ? (index - 1) : index;
Tom Sepez 2014/08/27 21:25:45 nit: maybe these should move outsize the loop, st
Bo Xu 2014/08/27 22:13:18 Done.
532 int col_pre = (col == 0) ? 8 : col; 535 int col_pre = (col == 0) ? 8 : col;
Tom Sepez 2014/08/27 21:35:33 8 seems like a weird value to assign to a variable
533 if( ((dest_buf[index] >> (7 - col)) & 1) ^ ((dest_buf[index_pre] >> (8 - col_pre)) & 1) ) { 536 if( ((dest_buf[index] >> (7 - col)) & 1) ^ ((dest_buf[index_pre] >> (8 - col_pre)) & 1) ) {
Tom Sepez 2014/08/27 21:35:33 This would need to change if you followed the abov
534 dest_buf[index] |= 1 << (7 - col); 537 dest_buf[index] |= 1 << (7 - col);
535 } else { 538 } else {
536 dest_buf[index] &= ~(1 << (7 - col)); 539 dest_buf[index] &= ~(1 << (7 - col));
537 } 540 }
538 } 541 }
539 return; 542 return;
540 } 543 }
541 int BytesPerPixel = BitsPerComponent * Colors / 8; 544 int BytesPerPixel = BitsPerComponent * Colors / 8;
542 if (BitsPerComponent == 16) { 545 if (BitsPerComponent == 16) {
543 for (int i = BytesPerPixel; i < row_size; i += 2) { 546 for (int i = BytesPerPixel; i < row_size; i += 2) {
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 dest_size = src_size + src_size / 1000 + 12; 938 dest_size = src_size + src_size / 1000 + 12;
936 dest_buf = FX_Alloc( FX_BYTE, dest_size); 939 dest_buf = FX_Alloc( FX_BYTE, dest_size);
937 if (dest_buf == NULL) { 940 if (dest_buf == NULL) {
938 return FALSE; 941 return FALSE;
939 } 942 }
940 unsigned long temp_size = dest_size; 943 unsigned long temp_size = dest_size;
941 FPDFAPI_FlateCompress(dest_buf, &temp_size, src_buf, src_size); 944 FPDFAPI_FlateCompress(dest_buf, &temp_size, src_buf, src_size);
942 dest_size = (FX_DWORD)temp_size; 945 dest_size = (FX_DWORD)temp_size;
943 return TRUE; 946 return TRUE;
944 } 947 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698