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

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

Issue 997273002: XFA: bound memcpy length in _png_load_bmp_attribute() (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 9 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 "../../../include/fxcodec/fx_codec.h" 7 #include "../../../include/fxcodec/fx_codec.h"
8 #include "../../../include/fxge/fx_dib.h" 8 #include "../../../include/fxge/fx_dib.h"
9 #include "codec_int.h" 9 #include "codec_int.h"
10 extern "C" { 10 extern "C" {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 FX_DWORD len; 62 FX_DWORD len;
63 FX_LPCSTR buf; 63 FX_LPCSTR buf;
64 int num_text; 64 int num_text;
65 png_textp text = NULL; 65 png_textp text = NULL;
66 png_get_text(png_ptr, info_ptr, &text, &num_text); 66 png_get_text(png_ptr, info_ptr, &text, &num_text);
67 for (i = 0; i < num_text; i++) { 67 for (i = 0; i < num_text; i++) {
68 len = (FX_DWORD)FXSYS_strlen(text[i].key); 68 len = (FX_DWORD)FXSYS_strlen(text[i].key);
69 buf = "Time"; 69 buf = "Time";
70 if (!FXSYS_memcmp32(buf, text[i].key, FX_MIN(len, FXSYS_strlen(buf)) )) { 70 if (!FXSYS_memcmp32(buf, text[i].key, FX_MIN(len, FXSYS_strlen(buf)) )) {
71 if (!bTime) { 71 if (!bTime) {
72 FXSYS_memset32(pAttribute->m_strTime, 0, 20); 72 FXSYS_memset32(pAttribute->m_strTime, 0, sizeof(pAttribute-> m_strTime));
73 FXSYS_memcpy32(pAttribute->m_strTime, text[i].text, text[i]. text_length); 73 FXSYS_memcpy32(pAttribute->m_strTime, text[i].text,
74 FX_MIN(sizeof(pAttribute->m_strTime) - 1, tex t[i].text_length));
74 } 75 }
75 } else { 76 } else {
76 buf = "Author"; 77 buf = "Author";
77 if (!FXSYS_memcmp32(buf, text[i].key, FX_MIN(len, FXSYS_strlen(b uf)))) { 78 if (!FXSYS_memcmp32(buf, text[i].key, FX_MIN(len, FXSYS_strlen(b uf)))) {
78 pAttribute->m_strAuthor.Empty(); 79 pAttribute->m_strAuthor.Empty();
79 pAttribute->m_strAuthor.Load((FX_LPBYTE)text[i].text, (FX_ST RSIZE)text[i].text_length); 80 pAttribute->m_strAuthor.Load((FX_LPBYTE)text[i].text, (FX_ST RSIZE)text[i].text_length);
80 } 81 }
81 } 82 }
82 } 83 }
83 #endif 84 #endif
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 FXPNG_Context* p = (FXPNG_Context*)pContext; 239 FXPNG_Context* p = (FXPNG_Context*)pContext;
239 if(setjmp(png_jmpbuf(p->png_ptr))) { 240 if(setjmp(png_jmpbuf(p->png_ptr))) {
240 if (pAttribute && 0 == FXSYS_strcmp(m_szLastError, "Read Header Callback Error")) { 241 if (pAttribute && 0 == FXSYS_strcmp(m_szLastError, "Read Header Callback Error")) {
241 _png_load_bmp_attribute(p->png_ptr, p->info_ptr, pAttribute); 242 _png_load_bmp_attribute(p->png_ptr, p->info_ptr, pAttribute);
242 } 243 }
243 return FALSE; 244 return FALSE;
244 } 245 }
245 png_process_data(p->png_ptr, p->info_ptr, (FX_LPBYTE)src_buf, src_size); 246 png_process_data(p->png_ptr, p->info_ptr, (FX_LPBYTE)src_buf, src_size);
246 return TRUE; 247 return TRUE;
247 } 248 }
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