summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2017-09-27 15:31:20 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-09-27 20:01:56 +0000
commitc9de55bbfb8e55022476d972d183501cbf0216ad (patch)
tree603efc65683764c02c8e72fe909be8481f75da6f /core
parent36a155d1f3a9d9f315655a20d583c13644ef1f3e (diff)
downloadpdfium-c9de55bbfb8e55022476d972d183501cbf0216ad.tar.xz
Remove error strings from BMP decoding path
These are error strings are set but never used for anything. BUG=pdfium:907 Change-Id: I08d9547009116f7386d15b4a965b9a99c7bf1997 Reviewed-on: https://pdfium-review.googlesource.com/15010 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'core')
-rw-r--r--core/fxcodec/codec/ccodec_bmpmodule.cpp2
-rw-r--r--core/fxcodec/lbmp/fx_bmp.cpp54
-rw-r--r--core/fxcodec/lbmp/fx_bmp.h5
3 files changed, 27 insertions, 34 deletions
diff --git a/core/fxcodec/codec/ccodec_bmpmodule.cpp b/core/fxcodec/codec/ccodec_bmpmodule.cpp
index a76cc3c6f7..b2fcca869b 100644
--- a/core/fxcodec/codec/ccodec_bmpmodule.cpp
+++ b/core/fxcodec/codec/ccodec_bmpmodule.cpp
@@ -16,7 +16,6 @@
CBmpContext::CBmpContext(CCodec_BmpModule* pModule,
CCodec_BmpModule::Delegate* pDelegate)
: m_pModule(pModule), m_pDelegate(pDelegate) {
- memset(m_szLastError, 0, sizeof(m_szLastError));
}
CBmpContext::~CBmpContext() {}
@@ -29,7 +28,6 @@ std::unique_ptr<CCodec_BmpModule::Context> CCodec_BmpModule::Start(
Delegate* pDelegate) {
auto p = pdfium::MakeUnique<CBmpContext>(this, pDelegate);
p->m_Bmp.context_ptr = p.get();
- p->m_Bmp.err_ptr = p->m_szLastError;
return p;
}
diff --git a/core/fxcodec/lbmp/fx_bmp.cpp b/core/fxcodec/lbmp/fx_bmp.cpp
index f445453c65..e705555522 100644
--- a/core/fxcodec/lbmp/fx_bmp.cpp
+++ b/core/fxcodec/lbmp/fx_bmp.cpp
@@ -33,8 +33,7 @@ uint16_t GetWord_LSBFirst(uint8_t* p) {
}
BMPDecompressor::BMPDecompressor()
- : err_ptr(nullptr),
- context_ptr(nullptr),
+ : context_ptr(nullptr),
next_in(nullptr),
header_offset(0),
width(0),
@@ -64,8 +63,7 @@ BMPDecompressor::BMPDecompressor()
BMPDecompressor::~BMPDecompressor() {}
-void BMPDecompressor::Error(const char* err_msg) {
- strncpy(err_ptr, err_msg, BMP_MAX_ERROR_SIZE - 1);
+void BMPDecompressor::Error() {
longjmp(jmpbuf, 1);
}
@@ -96,7 +94,7 @@ int32_t BMPDecompressor::ReadHeader() {
data_size =
FXDWORD_GET_LSBFIRST(reinterpret_cast<uint8_t*>(&pBmp_header->bfSize));
if (pBmp_header->bfType != BMP_SIGNATURE) {
- Error("Not A Bmp Image");
+ Error();
NOTREACHED();
}
if (avail_in < sizeof(uint32_t)) {
@@ -181,12 +179,12 @@ int32_t BMPDecompressor::ReadHeader() {
if (compress_flag == BMP_RGB && biPlanes == 1 && color_used == 0)
break;
}
- Error("Unsupported Bmp File");
+ Error();
NOTREACHED();
}
}
if (width > BMP_MAX_WIDTH || compress_flag > BMP_BITFIELDS) {
- Error("The Bmp File Is Corrupt");
+ Error();
NOTREACHED();
}
switch (bitCounts) {
@@ -196,14 +194,14 @@ int32_t BMPDecompressor::ReadHeader() {
case 16:
case 24: {
if (color_used > 1U << bitCounts) {
- Error("The Bmp File Is Corrupt");
+ Error();
NOTREACHED();
}
}
case 32:
break;
default:
- Error("The Bmp File Is Corrupt");
+ Error();
NOTREACHED();
}
src_row_bytes = BMP_WIDTHBYTES(width, bitCounts);
@@ -227,7 +225,7 @@ int32_t BMPDecompressor::ReadHeader() {
out_row_buffer.clear();
if (out_row_bytes <= 0) {
- Error("The Bmp File Is Corrupt");
+ Error();
NOTREACHED();
}
@@ -238,7 +236,7 @@ int32_t BMPDecompressor::ReadHeader() {
skip_size_org = skip_size;
if (compress_flag == BMP_BITFIELDS) {
if (bitCounts != 16 && bitCounts != 32) {
- Error("The Bmp File Is Corrupt");
+ Error();
NOTREACHED();
}
uint32_t* mask;
@@ -252,7 +250,7 @@ int32_t BMPDecompressor::ReadHeader() {
mask_blue = FXDWORD_GET_LSBFIRST(reinterpret_cast<uint8_t*>(&mask[2]));
if (mask_red & mask_green || mask_red & mask_blue ||
mask_green & mask_blue) {
- Error("The Bitfield Bmp File Is Corrupt");
+ Error();
NOTREACHED();
}
header_offset = std::max(header_offset, 26 + img_ifh_size);
@@ -314,14 +312,14 @@ int32_t BMPDecompressor::DecodeImage() {
avail_in = 0;
if (!GetDataPosition(header_offset)) {
decode_status = BMP_D_STATUS_TAIL;
- Error("The Bmp File Is Corrupt, Unexpected Stream Offset");
+ Error();
NOTREACHED();
}
row_num = 0;
SaveDecodingStatus(BMP_D_STATUS_DATA);
}
if (decode_status != BMP_D_STATUS_DATA || !ValidateFlag()) {
- Error("Any Uncontrol Error");
+ Error();
NOTREACHED();
}
switch (compress_flag) {
@@ -339,7 +337,7 @@ int32_t BMPDecompressor::DecodeImage() {
bool BMPDecompressor::ValidateColorIndex(uint8_t val) {
if (val >= pal_num) {
- Error("A color index exceeds range determined by pal_num");
+ Error();
NOTREACHED();
}
return true;
@@ -433,7 +431,7 @@ int32_t BMPDecompressor::DecodeRLE8() {
case RLE_EOL: {
if (row_num >= height) {
SaveDecodingStatus(BMP_D_STATUS_TAIL);
- Error("The Bmp File Is Corrupt");
+ Error();
NOTREACHED();
}
ReadScanline(imgTB_flag ? row_num++ : (height - 1 - row_num++),
@@ -460,7 +458,7 @@ int32_t BMPDecompressor::DecodeRLE8() {
col_num += delta_ptr[0];
size_t bmp_row_num_next = row_num + delta_ptr[1];
if (col_num >= out_row_bytes || bmp_row_num_next >= height) {
- Error("The Bmp File Is Corrupt Or Not Supported");
+ Error();
NOTREACHED();
}
while (row_num < bmp_row_num_next) {
@@ -473,7 +471,7 @@ int32_t BMPDecompressor::DecodeRLE8() {
int32_t avail_size = out_row_bytes - col_num;
if (!avail_size ||
static_cast<int32_t>(*first_byte_ptr) > avail_size) {
- Error("The Bmp File Is Corrupt");
+ Error();
NOTREACHED();
}
if (!ReadData(&second_byte_ptr, *first_byte_ptr & 1
@@ -495,7 +493,7 @@ int32_t BMPDecompressor::DecodeRLE8() {
default: {
int32_t avail_size = out_row_bytes - col_num;
if (!avail_size || static_cast<int32_t>(*first_byte_ptr) > avail_size) {
- Error("The Bmp File Is Corrupt");
+ Error();
NOTREACHED();
}
if (!ReadData(&second_byte_ptr, 1)) {
@@ -511,7 +509,7 @@ int32_t BMPDecompressor::DecodeRLE8() {
}
}
}
- Error("Any Uncontrol Error");
+ Error();
NOTREACHED();
}
@@ -534,7 +532,7 @@ int32_t BMPDecompressor::DecodeRLE4() {
case RLE_EOL: {
if (row_num >= height) {
SaveDecodingStatus(BMP_D_STATUS_TAIL);
- Error("The Bmp File Is Corrupt");
+ Error();
NOTREACHED();
}
ReadScanline(imgTB_flag ? row_num++ : (height - 1 - row_num++),
@@ -561,7 +559,7 @@ int32_t BMPDecompressor::DecodeRLE4() {
col_num += delta_ptr[0];
size_t bmp_row_num_next = row_num + delta_ptr[1];
if (col_num >= out_row_bytes || bmp_row_num_next >= height) {
- Error("The Bmp File Is Corrupt Or Not Supported");
+ Error();
NOTREACHED();
}
while (row_num < bmp_row_num_next) {
@@ -573,13 +571,13 @@ int32_t BMPDecompressor::DecodeRLE4() {
default: {
int32_t avail_size = out_row_bytes - col_num;
if (!avail_size) {
- Error("The Bmp File Is Corrupt");
+ Error();
NOTREACHED();
}
uint8_t size = HalfRoundUp(*first_byte_ptr);
if (static_cast<int32_t>(*first_byte_ptr) > avail_size) {
if (size + (col_num >> 1) > src_row_bytes) {
- Error("The Bmp File Is Corrupt");
+ Error();
NOTREACHED();
}
*first_byte_ptr = avail_size - 1;
@@ -602,13 +600,13 @@ int32_t BMPDecompressor::DecodeRLE4() {
default: {
int32_t avail_size = out_row_bytes - col_num;
if (!avail_size) {
- Error("The Bmp File Is Corrupt");
+ Error();
NOTREACHED();
}
if (static_cast<int32_t>(*first_byte_ptr) > avail_size) {
uint8_t size = HalfRoundUp(*first_byte_ptr);
if (size + (col_num >> 1) > src_row_bytes) {
- Error("The Bmp File Is Corrupt");
+ Error();
NOTREACHED();
}
*first_byte_ptr = avail_size - 1;
@@ -628,7 +626,7 @@ int32_t BMPDecompressor::DecodeRLE4() {
}
}
}
- Error("Any Uncontrol Error");
+ Error();
NOTREACHED();
}
@@ -669,7 +667,7 @@ void BMPDecompressor::SetHeight(int32_t signed_height) {
return;
}
if (signed_height == std::numeric_limits<int>::min()) {
- Error("Unsupported height");
+ Error();
NOTREACHED();
}
height = -signed_height;
diff --git a/core/fxcodec/lbmp/fx_bmp.h b/core/fxcodec/lbmp/fx_bmp.h
index 72dbfa5b03..ca55885aef 100644
--- a/core/fxcodec/lbmp/fx_bmp.h
+++ b/core/fxcodec/lbmp/fx_bmp.h
@@ -35,7 +35,6 @@
#define BMP_BITFIELDS 3L
#define BMP_BIT_555 0
#define BMP_BIT_565 1
-#define BMP_MAX_ERROR_SIZE 256
// Limit width to (MAXINT32 - 31) / 32
#define BMP_MAX_WIDTH 67108863
#pragma pack(1)
@@ -73,14 +72,13 @@ class BMPDecompressor {
BMPDecompressor();
~BMPDecompressor();
- void Error(const char* err_msg);
+ void Error();
int32_t DecodeImage();
int32_t ReadHeader();
void SetInputBuffer(uint8_t* src_buf, uint32_t src_size);
uint32_t GetAvailInput(uint8_t** avail_buf);
jmp_buf jmpbuf;
- char* err_ptr;
void* context_ptr;
@@ -136,7 +134,6 @@ class CBmpContext : public CCodec_BmpModule::Context {
BMPDecompressor m_Bmp;
UnownedPtr<CCodec_BmpModule> const m_pModule;
UnownedPtr<CCodec_BmpModule::Delegate> const m_pDelegate;
- char m_szLastError[256];
};
uint16_t GetWord_LSBFirst(uint8_t* p);