| 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 "../include/fsdk_define.h" |    7 #include "../include/fsdk_define.h" | 
|    8 #include "../include/fsdk_mgr.h" |    8 #include "../include/fsdk_mgr.h" | 
|    9 #include "../include/fpdfview.h" |    9 #include "../include/fpdfview.h" | 
|   10 #include "../include/fsdk_rendercontext.h" |   10 #include "../include/fsdk_rendercontext.h" | 
|   11 #include "../include/fpdf_progressive.h" |   11 #include "../include/fpdf_progressive.h" | 
|   12 #include "../include/fpdf_ext.h" |   12 #include "../include/fpdf_ext.h" | 
|   13 #include "../../third_party/numerics/safe_conversions_impl.h" |   13 #include "../../third_party/base/numerics/safe_conversions_impl.h" | 
|   14  |   14  | 
|   15 CPDF_CustomAccess::CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess) |   15 CPDF_CustomAccess::CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess) | 
|   16 { |   16 { | 
|   17         if (pFileAccess) |   17         if (pFileAccess) | 
|   18                 m_FileAccess = *pFileAccess; |   18                 m_FileAccess = *pFileAccess; | 
|   19 } |   19 } | 
|   20  |   20  | 
|   21 FX_BOOL CPDF_CustomAccess::ReadBlock(void* buffer, FX_FILESIZE offset, size_t si
     ze) |   21 FX_BOOL CPDF_CustomAccess::ReadBlock(void* buffer, FX_FILESIZE offset, size_t si
     ze) | 
|   22 { |   22 { | 
|   23     if (offset < 0) { |   23     if (offset < 0) { | 
|   24         return FALSE; |   24         return FALSE; | 
|   25     } |   25     } | 
|   26     FX_SAFE_FILESIZE newPos = base::checked_cast<FX_FILESIZE, size_t>(size); |   26     FX_SAFE_FILESIZE newPos = third_party::base::checked_cast<FX_FILESIZE, size_
     t>(size); | 
|   27     newPos += offset; |   27     newPos += offset; | 
|   28     if (!newPos.IsValid() || newPos.ValueOrDie() > m_FileAccess.m_FileLen) { |   28     if (!newPos.IsValid() || newPos.ValueOrDie() > m_FileAccess.m_FileLen) { | 
|   29         return FALSE; |   29         return FALSE; | 
|   30     } |   30     } | 
|   31     return m_FileAccess.m_GetBlock(m_FileAccess.m_Param, offset,(FX_LPBYTE) buff
     er, size); |   31     return m_FileAccess.m_GetBlock(m_FileAccess.m_Param, offset,(FX_LPBYTE) buff
     er, size); | 
|   32 } |   32 } | 
|   33  |   33  | 
|   34 //0 bit: FPDF_POLICY_MACHINETIME_ACCESS |   34 //0 bit: FPDF_POLICY_MACHINETIME_ACCESS | 
|   35 static FX_DWORD foxit_sandbox_policy = 0xFFFFFFFF; |   35 static FX_DWORD foxit_sandbox_policy = 0xFFFFFFFF; | 
|   36  |   36  | 
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  202 public: |  202 public: | 
|  203         CMemFile(FX_BYTE* pBuf, FX_FILESIZE size):m_pBuf(pBuf),m_size(size) {} |  203         CMemFile(FX_BYTE* pBuf, FX_FILESIZE size):m_pBuf(pBuf),m_size(size) {} | 
|  204  |  204  | 
|  205         virtual void                    Release() {delete this;} |  205         virtual void                    Release() {delete this;} | 
|  206         virtual FX_FILESIZE             GetSize() {return m_size;} |  206         virtual FX_FILESIZE             GetSize() {return m_size;} | 
|  207         virtual FX_BOOL                 ReadBlock(void* buffer, FX_FILESIZE offs
     et, size_t size)  |  207         virtual FX_BOOL                 ReadBlock(void* buffer, FX_FILESIZE offs
     et, size_t size)  | 
|  208         { |  208         { | 
|  209             if (offset < 0) { |  209             if (offset < 0) { | 
|  210                 return FALSE; |  210                 return FALSE; | 
|  211             } |  211             } | 
|  212             FX_SAFE_FILESIZE newPos = base::checked_cast<FX_FILESIZE, size_t>(si
     ze); |  212             FX_SAFE_FILESIZE newPos = third_party::base::checked_cast<FX_FILESIZ
     E, size_t>(size); | 
|  213             newPos += offset; |  213             newPos += offset; | 
|  214             if (!newPos.IsValid() || newPos.ValueOrDie() > (FX_DWORD)m_size) { |  214             if (!newPos.IsValid() || newPos.ValueOrDie() > (FX_DWORD)m_size) { | 
|  215                 return FALSE; |  215                 return FALSE; | 
|  216             } |  216             } | 
|  217             FXSYS_memcpy(buffer, m_pBuf+offset, size); |  217             FXSYS_memcpy(buffer, m_pBuf+offset, size); | 
|  218             return TRUE; |  218             return TRUE; | 
|  219         } |  219         } | 
|  220 private: |  220 private: | 
|  221         FX_BYTE* m_pBuf; |  221         FX_BYTE* m_pBuf; | 
|  222         FX_FILESIZE m_size; |  222         FX_FILESIZE m_size; | 
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  859     if (!buffer) { |  859     if (!buffer) { | 
|  860         buflen = len; |  860         buflen = len; | 
|  861     } else if (buflen >= len) { |  861     } else if (buflen >= len) { | 
|  862         memcpy(buffer, utf16Name.c_str(), len); |  862         memcpy(buffer, utf16Name.c_str(), len); | 
|  863         buflen = len; |  863         buflen = len; | 
|  864     } else { |  864     } else { | 
|  865         buflen = -1; |  865         buflen = -1; | 
|  866     } |  866     } | 
|  867     return (FPDF_DEST)pDestObj; |  867     return (FPDF_DEST)pDestObj; | 
|  868 } |  868 } | 
| OLD | NEW |