| OLD | NEW |
| 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 <limits.h> | 7 #include <limits.h> |
| 8 #include "../../../include/fpdfapi/fpdf_parser.h" | 8 #include "../../../include/fpdfapi/fpdf_parser.h" |
| 9 #include "../../../include/fpdfapi/fpdf_module.h" | 9 #include "../../../include/fpdfapi/fpdf_module.h" |
| 10 #include "../../../include/fxcodec/fx_codec.h" | 10 #include "../../../include/fxcodec/fx_codec.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 } | 73 } |
| 74 if (zcount * 4 > UINT_MAX - (pos - zcount)) { | 74 if (zcount * 4 > UINT_MAX - (pos - zcount)) { |
| 75 return (FX_DWORD)-1; | 75 return (FX_DWORD)-1; |
| 76 } | 76 } |
| 77 dest_buf = FX_Alloc(uint8_t, zcount * 4 + (pos - zcount)); | 77 dest_buf = FX_Alloc(uint8_t, zcount * 4 + (pos - zcount)); |
| 78 int state = 0; | 78 int state = 0; |
| 79 uint32_t res = 0; | 79 uint32_t res = 0; |
| 80 pos = dest_size = 0; | 80 pos = dest_size = 0; |
| 81 while (pos < src_size) { | 81 while (pos < src_size) { |
| 82 uint8_t ch = src_buf[pos++]; | 82 uint8_t ch = src_buf[pos++]; |
| 83 if (ch == '\n' || ch == '\r' || ch == ' ' || ch == '\t') { | 83 if (PDFCharIsLineEnding(ch) || ch == ' ' || ch == '\t') |
| 84 continue; | 84 continue; |
| 85 } | 85 |
| 86 if (ch == 'z') { | 86 if (ch == 'z') { |
| 87 FXSYS_memset(dest_buf + dest_size, 0, 4); | 87 FXSYS_memset(dest_buf + dest_size, 0, 4); |
| 88 state = 0; | 88 state = 0; |
| 89 res = 0; | 89 res = 0; |
| 90 dest_size += 4; | 90 dest_size += 4; |
| 91 } else { | 91 } else { |
| 92 if (ch < '!' || ch > 'u') { | 92 if (ch < '!' || ch > 'u') { |
| 93 break; | 93 break; |
| 94 } | 94 } |
| 95 res = res * 85 + ch - 33; | 95 res = res * 85 + ch - 33; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 124 FX_DWORD i; | 124 FX_DWORD i; |
| 125 for (i = 0; i < src_size; i++) | 125 for (i = 0; i < src_size; i++) |
| 126 if (src_buf[i] == '>') { | 126 if (src_buf[i] == '>') { |
| 127 break; | 127 break; |
| 128 } | 128 } |
| 129 dest_buf = FX_Alloc(uint8_t, i / 2 + 1); | 129 dest_buf = FX_Alloc(uint8_t, i / 2 + 1); |
| 130 dest_size = 0; | 130 dest_size = 0; |
| 131 FX_BOOL bFirstDigit = TRUE; | 131 FX_BOOL bFirstDigit = TRUE; |
| 132 for (i = 0; i < src_size; i++) { | 132 for (i = 0; i < src_size; i++) { |
| 133 uint8_t ch = src_buf[i]; | 133 uint8_t ch = src_buf[i]; |
| 134 if (ch == ' ' || ch == '\n' || ch == '\t' || ch == '\r') { | 134 if (PDFCharIsLineEnding(ch) || ch == ' ' || ch == '\t') |
| 135 continue; | 135 continue; |
| 136 } | 136 |
| 137 int digit; | 137 int digit; |
| 138 if (ch <= '9' && ch >= '0') { | 138 if (ch <= '9' && ch >= '0') { |
| 139 digit = ch - '0'; | 139 digit = ch - '0'; |
| 140 } else if (ch <= 'f' && ch >= 'a') { | 140 } else if (ch <= 'f' && ch >= 'a') { |
| 141 digit = ch - 'a' + 10; | 141 digit = ch - 'a' + 10; |
| 142 } else if (ch <= 'F' && ch >= 'A') { | 142 } else if (ch <= 'F' && ch >= 'A') { |
| 143 digit = ch - 'A' + 10; | 143 digit = ch - 'A' + 10; |
| 144 } else if (ch == '>') { | 144 } else if (ch == '>') { |
| 145 i++; | 145 i++; |
| 146 break; | 146 break; |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 FX_DWORD src_size, | 573 FX_DWORD src_size, |
| 574 uint8_t*& dest_buf, | 574 uint8_t*& dest_buf, |
| 575 FX_DWORD& dest_size) { | 575 FX_DWORD& dest_size) { |
| 576 CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule(); | 576 CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule(); |
| 577 if (pEncoders) { | 577 if (pEncoders) { |
| 578 return pEncoders->GetFlateModule()->FlateOrLZWDecode( | 578 return pEncoders->GetFlateModule()->FlateOrLZWDecode( |
| 579 FALSE, src_buf, src_size, FALSE, 0, 0, 0, 0, 0, dest_buf, dest_size); | 579 FALSE, src_buf, src_size, FALSE, 0, 0, 0, 0, 0, dest_buf, dest_size); |
| 580 } | 580 } |
| 581 return 0; | 581 return 0; |
| 582 } | 582 } |
| OLD | NEW |