Jane Liu | 53aafa9 | 2017-07-12 19:55:02 -0400 | [diff] [blame] | 1 | // Copyright 2017 PDFium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "public/fpdf_attachment.h" |
| 6 | |
Jane Liu | 605fb60 | 2017-07-25 14:44:11 -0400 | [diff] [blame] | 7 | #include <memory> |
| 8 | #include <utility> |
| 9 | |
Lei Zhang | 2617056 | 2018-04-17 17:01:52 +0000 | [diff] [blame] | 10 | #include "constants/stream_dict_common.h" |
Jane Liu | 54a4214 | 2017-07-24 16:40:54 -0400 | [diff] [blame] | 11 | #include "core/fdrm/crypto/fx_crypt.h" |
Jane Liu | 54a4214 | 2017-07-24 16:40:54 -0400 | [diff] [blame] | 12 | #include "core/fpdfapi/parser/cpdf_array.h" |
Lei Zhang | 8153561 | 2018-10-09 21:15:17 +0000 | [diff] [blame^] | 13 | #include "core/fpdfapi/parser/cpdf_dictionary.h" |
Jane Liu | 53aafa9 | 2017-07-12 19:55:02 -0400 | [diff] [blame] | 14 | #include "core/fpdfapi/parser/cpdf_document.h" |
Jane Liu | 54a4214 | 2017-07-24 16:40:54 -0400 | [diff] [blame] | 15 | #include "core/fpdfapi/parser/cpdf_name.h" |
| 16 | #include "core/fpdfapi/parser/cpdf_number.h" |
| 17 | #include "core/fpdfapi/parser/cpdf_reference.h" |
Jane Liu | 18ae06d | 2017-07-18 10:15:16 -0400 | [diff] [blame] | 18 | #include "core/fpdfapi/parser/cpdf_string.h" |
| 19 | #include "core/fpdfapi/parser/fpdf_parser_decode.h" |
Jane Liu | 53aafa9 | 2017-07-12 19:55:02 -0400 | [diff] [blame] | 20 | #include "core/fpdfdoc/cpdf_filespec.h" |
| 21 | #include "core/fpdfdoc/cpdf_nametree.h" |
Jane Liu | 54a4214 | 2017-07-24 16:40:54 -0400 | [diff] [blame] | 22 | #include "core/fxcrt/cfx_datetime.h" |
| 23 | #include "core/fxcrt/fx_extension.h" |
Dan Sinclair | 00d47a6 | 2018-03-28 18:39:04 +0000 | [diff] [blame] | 24 | #include "fpdfsdk/cpdfsdk_helpers.h" |
Jane Liu | 53aafa9 | 2017-07-12 19:55:02 -0400 | [diff] [blame] | 25 | |
Jane Liu | 54a4214 | 2017-07-24 16:40:54 -0400 | [diff] [blame] | 26 | namespace { |
| 27 | |
Lei Zhang | df064df | 2017-08-31 02:33:27 -0700 | [diff] [blame] | 28 | constexpr char kChecksumKey[] = "CheckSum"; |
| 29 | |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 30 | ByteString CFXByteStringHexDecode(const ByteString& bsHex) { |
Lei Zhang | 8365e76 | 2018-09-11 07:57:48 +0000 | [diff] [blame] | 31 | std::unique_ptr<uint8_t, FxFreeDeleter> result; |
Jane Liu | 54a4214 | 2017-07-24 16:40:54 -0400 | [diff] [blame] | 32 | uint32_t size = 0; |
Tom Sepez | 1934a24 | 2018-08-29 19:32:47 +0000 | [diff] [blame] | 33 | HexDecode(bsHex.AsRawSpan(), &result, &size); |
Lei Zhang | 8365e76 | 2018-09-11 07:57:48 +0000 | [diff] [blame] | 34 | return ByteString(result.get(), size); |
Jane Liu | 54a4214 | 2017-07-24 16:40:54 -0400 | [diff] [blame] | 35 | } |
| 36 | |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 37 | ByteString GenerateMD5Base16(const void* contents, const unsigned long len) { |
Jane Liu | 54a4214 | 2017-07-24 16:40:54 -0400 | [diff] [blame] | 38 | uint8_t digest[16]; |
| 39 | CRYPT_MD5Generate(reinterpret_cast<const uint8_t*>(contents), len, digest); |
| 40 | char buf[32]; |
| 41 | for (int i = 0; i < 16; ++i) |
| 42 | FXSYS_IntToTwoHexChars(digest[i], &buf[i * 2]); |
| 43 | |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 44 | return ByteString(buf, 32); |
Jane Liu | 54a4214 | 2017-07-24 16:40:54 -0400 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | } // namespace |
| 48 | |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 49 | FPDF_EXPORT int FPDF_CALLCONV |
| 50 | FPDFDoc_GetAttachmentCount(FPDF_DOCUMENT document) { |
Jane Liu | 53aafa9 | 2017-07-12 19:55:02 -0400 | [diff] [blame] | 51 | CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); |
| 52 | if (!pDoc) |
| 53 | return 0; |
| 54 | |
| 55 | return CPDF_NameTree(pDoc, "EmbeddedFiles").GetCount(); |
| 56 | } |
| 57 | |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 58 | FPDF_EXPORT FPDF_ATTACHMENT FPDF_CALLCONV |
| 59 | FPDFDoc_AddAttachment(FPDF_DOCUMENT document, FPDF_WIDESTRING name) { |
Jane Liu | 54a4214 | 2017-07-24 16:40:54 -0400 | [diff] [blame] | 60 | CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 61 | WideString wsName = |
| 62 | WideString::FromUTF16LE(name, WideString::WStringLength(name)); |
Jane Liu | 54a4214 | 2017-07-24 16:40:54 -0400 | [diff] [blame] | 63 | if (!pDoc || wsName.IsEmpty()) |
| 64 | return nullptr; |
| 65 | |
| 66 | CPDF_Dictionary* pRoot = pDoc->GetRoot(); |
| 67 | if (!pRoot) |
| 68 | return nullptr; |
| 69 | |
| 70 | // Retrieve the document's Names dictionary; create it if missing. |
| 71 | CPDF_Dictionary* pNames = pRoot->GetDictFor("Names"); |
| 72 | if (!pNames) { |
| 73 | pNames = pDoc->NewIndirect<CPDF_Dictionary>(); |
Artem Strygin | fb72726 | 2018-06-11 18:19:57 +0000 | [diff] [blame] | 74 | pRoot->SetFor("Names", pNames->MakeReference(pDoc)); |
Jane Liu | 54a4214 | 2017-07-24 16:40:54 -0400 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | // Create the EmbeddedFiles dictionary if missing. |
| 78 | if (!pNames->GetDictFor("EmbeddedFiles")) { |
| 79 | CPDF_Dictionary* pFiles = pDoc->NewIndirect<CPDF_Dictionary>(); |
| 80 | pFiles->SetNewFor<CPDF_Array>("Names"); |
Artem Strygin | fb72726 | 2018-06-11 18:19:57 +0000 | [diff] [blame] | 81 | pNames->SetFor("EmbeddedFiles", pFiles->MakeReference(pDoc)); |
Jane Liu | 54a4214 | 2017-07-24 16:40:54 -0400 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | // Set up the basic entries in the filespec dictionary. |
| 85 | CPDF_Dictionary* pFile = pDoc->NewIndirect<CPDF_Dictionary>(); |
| 86 | pFile->SetNewFor<CPDF_Name>("Type", "Filespec"); |
| 87 | pFile->SetNewFor<CPDF_String>("UF", wsName); |
Lei Zhang | 2617056 | 2018-04-17 17:01:52 +0000 | [diff] [blame] | 88 | pFile->SetNewFor<CPDF_String>(pdfium::stream::kF, wsName); |
Jane Liu | 54a4214 | 2017-07-24 16:40:54 -0400 | [diff] [blame] | 89 | |
| 90 | // Add the new attachment name and filespec into the document's EmbeddedFiles. |
| 91 | CPDF_NameTree nameTree(pDoc, "EmbeddedFiles"); |
Artem Strygin | fb72726 | 2018-06-11 18:19:57 +0000 | [diff] [blame] | 92 | if (!nameTree.AddValueAndName(pFile->MakeReference(pDoc), wsName)) { |
Jane Liu | 54a4214 | 2017-07-24 16:40:54 -0400 | [diff] [blame] | 93 | return nullptr; |
| 94 | } |
| 95 | |
Tom Sepez | 525147a | 2018-05-03 17:19:53 +0000 | [diff] [blame] | 96 | return FPDFAttachmentFromCPDFObject(pFile); |
Jane Liu | 54a4214 | 2017-07-24 16:40:54 -0400 | [diff] [blame] | 97 | } |
| 98 | |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 99 | FPDF_EXPORT FPDF_ATTACHMENT FPDF_CALLCONV |
| 100 | FPDFDoc_GetAttachment(FPDF_DOCUMENT document, int index) { |
Jane Liu | 53aafa9 | 2017-07-12 19:55:02 -0400 | [diff] [blame] | 101 | CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); |
| 102 | if (!pDoc || index < 0) |
Jane Liu | 18ae06d | 2017-07-18 10:15:16 -0400 | [diff] [blame] | 103 | return nullptr; |
Jane Liu | 53aafa9 | 2017-07-12 19:55:02 -0400 | [diff] [blame] | 104 | |
| 105 | CPDF_NameTree nameTree(pDoc, "EmbeddedFiles"); |
| 106 | if (static_cast<size_t>(index) >= nameTree.GetCount()) |
Jane Liu | 18ae06d | 2017-07-18 10:15:16 -0400 | [diff] [blame] | 107 | return nullptr; |
Jane Liu | 53aafa9 | 2017-07-12 19:55:02 -0400 | [diff] [blame] | 108 | |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 109 | WideString csName; |
Tom Sepez | 525147a | 2018-05-03 17:19:53 +0000 | [diff] [blame] | 110 | return FPDFAttachmentFromCPDFObject( |
| 111 | nameTree.LookupValueAndName(index, &csName)); |
Jane Liu | 18ae06d | 2017-07-18 10:15:16 -0400 | [diff] [blame] | 112 | } |
| 113 | |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 114 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
| 115 | FPDFDoc_DeleteAttachment(FPDF_DOCUMENT document, int index) { |
Jane Liu | f63e813 | 2017-07-25 18:11:27 -0400 | [diff] [blame] | 116 | CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); |
| 117 | if (!pDoc || index < 0) |
| 118 | return false; |
| 119 | |
| 120 | CPDF_NameTree nameTree(pDoc, "EmbeddedFiles"); |
| 121 | if (static_cast<size_t>(index) >= nameTree.GetCount()) |
| 122 | return false; |
| 123 | |
| 124 | return nameTree.DeleteValueAndName(index); |
| 125 | } |
| 126 | |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 127 | FPDF_EXPORT unsigned long FPDF_CALLCONV |
Jane Liu | 18ae06d | 2017-07-18 10:15:16 -0400 | [diff] [blame] | 128 | FPDFAttachment_GetName(FPDF_ATTACHMENT attachment, |
| 129 | void* buffer, |
| 130 | unsigned long buflen) { |
| 131 | CPDF_Object* pFile = CPDFObjectFromFPDFAttachment(attachment); |
Jane Liu | 53aafa9 | 2017-07-12 19:55:02 -0400 | [diff] [blame] | 132 | if (!pFile) |
| 133 | return 0; |
| 134 | |
Jane Liu | 18ae06d | 2017-07-18 10:15:16 -0400 | [diff] [blame] | 135 | return Utf16EncodeMaybeCopyAndReturnLength(CPDF_FileSpec(pFile).GetFileName(), |
| 136 | buffer, buflen); |
| 137 | } |
Jane Liu | 53aafa9 | 2017-07-12 19:55:02 -0400 | [diff] [blame] | 138 | |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 139 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
Lei Zhang | df064df | 2017-08-31 02:33:27 -0700 | [diff] [blame] | 140 | FPDFAttachment_HasKey(FPDF_ATTACHMENT attachment, FPDF_BYTESTRING key) { |
Jane Liu | 18ae06d | 2017-07-18 10:15:16 -0400 | [diff] [blame] | 141 | CPDF_Object* pFile = CPDFObjectFromFPDFAttachment(attachment); |
| 142 | if (!pFile) |
| 143 | return 0; |
| 144 | |
| 145 | CPDF_Dictionary* pParamsDict = CPDF_FileSpec(pFile).GetParamsDict(); |
Lei Zhang | df064df | 2017-08-31 02:33:27 -0700 | [diff] [blame] | 146 | return pParamsDict ? pParamsDict->KeyExist(key) : 0; |
Jane Liu | 18ae06d | 2017-07-18 10:15:16 -0400 | [diff] [blame] | 147 | } |
| 148 | |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 149 | FPDF_EXPORT FPDF_OBJECT_TYPE FPDF_CALLCONV |
Lei Zhang | df064df | 2017-08-31 02:33:27 -0700 | [diff] [blame] | 150 | FPDFAttachment_GetValueType(FPDF_ATTACHMENT attachment, FPDF_BYTESTRING key) { |
Jane Liu | 18ae06d | 2017-07-18 10:15:16 -0400 | [diff] [blame] | 151 | if (!FPDFAttachment_HasKey(attachment, key)) |
| 152 | return FPDF_OBJECT_UNKNOWN; |
| 153 | |
Lei Zhang | df064df | 2017-08-31 02:33:27 -0700 | [diff] [blame] | 154 | CPDF_FileSpec spec(CPDFObjectFromFPDFAttachment(attachment)); |
| 155 | CPDF_Object* pObj = spec.GetParamsDict()->GetObjectFor(key); |
| 156 | return pObj ? pObj->GetType() : FPDF_OBJECT_UNKNOWN; |
Jane Liu | 18ae06d | 2017-07-18 10:15:16 -0400 | [diff] [blame] | 157 | } |
| 158 | |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 159 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
Jane Liu | 54a4214 | 2017-07-24 16:40:54 -0400 | [diff] [blame] | 160 | FPDFAttachment_SetStringValue(FPDF_ATTACHMENT attachment, |
Lei Zhang | df064df | 2017-08-31 02:33:27 -0700 | [diff] [blame] | 161 | FPDF_BYTESTRING key, |
Jane Liu | 54a4214 | 2017-07-24 16:40:54 -0400 | [diff] [blame] | 162 | FPDF_WIDESTRING value) { |
| 163 | CPDF_Object* pFile = CPDFObjectFromFPDFAttachment(attachment); |
| 164 | if (!pFile) |
| 165 | return false; |
| 166 | |
| 167 | CPDF_Dictionary* pParamsDict = CPDF_FileSpec(pFile).GetParamsDict(); |
| 168 | if (!pParamsDict) |
| 169 | return false; |
| 170 | |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 171 | ByteString bsKey = key; |
| 172 | ByteString bsValue = CFXByteStringFromFPDFWideString(value); |
Lei Zhang | df064df | 2017-08-31 02:33:27 -0700 | [diff] [blame] | 173 | bool bEncodedAsHex = bsKey == kChecksumKey; |
Jane Liu | 54a4214 | 2017-07-24 16:40:54 -0400 | [diff] [blame] | 174 | if (bEncodedAsHex) |
| 175 | bsValue = CFXByteStringHexDecode(bsValue); |
| 176 | |
| 177 | pParamsDict->SetNewFor<CPDF_String>(bsKey, bsValue, bEncodedAsHex); |
| 178 | return true; |
| 179 | } |
| 180 | |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 181 | FPDF_EXPORT unsigned long FPDF_CALLCONV |
Jane Liu | 18ae06d | 2017-07-18 10:15:16 -0400 | [diff] [blame] | 182 | FPDFAttachment_GetStringValue(FPDF_ATTACHMENT attachment, |
Lei Zhang | df064df | 2017-08-31 02:33:27 -0700 | [diff] [blame] | 183 | FPDF_BYTESTRING key, |
Jane Liu | 18ae06d | 2017-07-18 10:15:16 -0400 | [diff] [blame] | 184 | void* buffer, |
| 185 | unsigned long buflen) { |
| 186 | CPDF_Object* pFile = CPDFObjectFromFPDFAttachment(attachment); |
| 187 | if (!pFile) |
| 188 | return 0; |
| 189 | |
| 190 | CPDF_Dictionary* pParamsDict = CPDF_FileSpec(pFile).GetParamsDict(); |
| 191 | if (!pParamsDict) |
| 192 | return 0; |
| 193 | |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 194 | ByteString bsKey = key; |
| 195 | WideString value = pParamsDict->GetUnicodeTextFor(bsKey); |
Lei Zhang | df064df | 2017-08-31 02:33:27 -0700 | [diff] [blame] | 196 | if (bsKey == kChecksumKey && !value.IsEmpty()) { |
Jane Liu | 18ae06d | 2017-07-18 10:15:16 -0400 | [diff] [blame] | 197 | CPDF_String* stringValue = pParamsDict->GetObjectFor(bsKey)->AsString(); |
| 198 | if (stringValue->IsHex()) { |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 199 | ByteString encoded = PDF_EncodeString(stringValue->GetString(), true); |
Lei Zhang | df064df | 2017-08-31 02:33:27 -0700 | [diff] [blame] | 200 | value = CPDF_String(nullptr, encoded, false).GetUnicodeText(); |
Jane Liu | 18ae06d | 2017-07-18 10:15:16 -0400 | [diff] [blame] | 201 | } |
| 202 | } |
| 203 | |
| 204 | return Utf16EncodeMaybeCopyAndReturnLength(value, buffer, buflen); |
| 205 | } |
| 206 | |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 207 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
| 208 | FPDFAttachment_SetFile(FPDF_ATTACHMENT attachment, |
| 209 | FPDF_DOCUMENT document, |
| 210 | const void* contents, |
| 211 | const unsigned long len) { |
Jane Liu | 54a4214 | 2017-07-24 16:40:54 -0400 | [diff] [blame] | 212 | CPDF_Object* pFile = CPDFObjectFromFPDFAttachment(attachment); |
| 213 | CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); |
| 214 | if (!pFile || !pFile->IsDictionary() || !pDoc || len > INT_MAX) |
| 215 | return false; |
| 216 | |
| 217 | // An empty content must have a zero length. |
| 218 | if (!contents && len != 0) |
| 219 | return false; |
| 220 | |
| 221 | // Create a dictionary for the new embedded file stream. |
| 222 | auto pFileStreamDict = pdfium::MakeUnique<CPDF_Dictionary>(); |
| 223 | CPDF_Dictionary* pParamsDict = |
| 224 | pFileStreamDict->SetNewFor<CPDF_Dictionary>("Params"); |
| 225 | |
| 226 | // Set the size of the new file in the dictionary. |
Lei Zhang | 2617056 | 2018-04-17 17:01:52 +0000 | [diff] [blame] | 227 | pFileStreamDict->SetNewFor<CPDF_Number>(pdfium::stream::kDL, |
| 228 | static_cast<int>(len)); |
Jane Liu | 54a4214 | 2017-07-24 16:40:54 -0400 | [diff] [blame] | 229 | pParamsDict->SetNewFor<CPDF_Number>("Size", static_cast<int>(len)); |
| 230 | |
| 231 | // Set the creation date of the new attachment in the dictionary. |
Dan Sinclair | ec2209d | 2017-11-16 22:08:27 +0000 | [diff] [blame] | 232 | CFX_DateTime dateTime = CFX_DateTime::Now(); |
Dan Sinclair | 1c4735a | 2017-11-16 22:08:07 +0000 | [diff] [blame] | 233 | pParamsDict->SetNewFor<CPDF_String>( |
| 234 | "CreationDate", |
| 235 | ByteString::Format("D:%d%02d%02d%02d%02d%02d", dateTime.GetYear(), |
| 236 | dateTime.GetMonth(), dateTime.GetDay(), |
| 237 | dateTime.GetHour(), dateTime.GetMinute(), |
| 238 | dateTime.GetSecond()), |
| 239 | false); |
Jane Liu | 54a4214 | 2017-07-24 16:40:54 -0400 | [diff] [blame] | 240 | |
| 241 | // Set the checksum of the new attachment in the dictionary. |
| 242 | pParamsDict->SetNewFor<CPDF_String>( |
Lei Zhang | df064df | 2017-08-31 02:33:27 -0700 | [diff] [blame] | 243 | kChecksumKey, CFXByteStringHexDecode(GenerateMD5Base16(contents, len)), |
Jane Liu | 54a4214 | 2017-07-24 16:40:54 -0400 | [diff] [blame] | 244 | true); |
| 245 | |
| 246 | // Create the file stream and have the filespec dictionary link to it. |
| 247 | std::unique_ptr<uint8_t, FxFreeDeleter> stream(FX_Alloc(uint8_t, len)); |
| 248 | memcpy(stream.get(), contents, len); |
| 249 | CPDF_Stream* pFileStream = pDoc->NewIndirect<CPDF_Stream>( |
| 250 | std::move(stream), len, std::move(pFileStreamDict)); |
| 251 | CPDF_Dictionary* pEFDict = |
| 252 | pFile->AsDictionary()->SetNewFor<CPDF_Dictionary>("EF"); |
Artem Strygin | fb72726 | 2018-06-11 18:19:57 +0000 | [diff] [blame] | 253 | pEFDict->SetFor("F", pFileStream->MakeReference(pDoc)); |
Jane Liu | 54a4214 | 2017-07-24 16:40:54 -0400 | [diff] [blame] | 254 | return true; |
| 255 | } |
| 256 | |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 257 | FPDF_EXPORT unsigned long FPDF_CALLCONV |
Jane Liu | 18ae06d | 2017-07-18 10:15:16 -0400 | [diff] [blame] | 258 | FPDFAttachment_GetFile(FPDF_ATTACHMENT attachment, |
| 259 | void* buffer, |
| 260 | unsigned long buflen) { |
| 261 | CPDF_Object* pFile = CPDFObjectFromFPDFAttachment(attachment); |
| 262 | if (!pFile) |
| 263 | return 0; |
| 264 | |
| 265 | CPDF_Stream* pFileStream = CPDF_FileSpec(pFile).GetFileStream(); |
| 266 | if (!pFileStream) |
| 267 | return 0; |
| 268 | |
Jane Liu | 548334e | 2017-08-03 16:33:40 -0400 | [diff] [blame] | 269 | return DecodeStreamMaybeCopyAndReturnLength(pFileStream, buffer, buflen); |
Jane Liu | 53aafa9 | 2017-07-12 19:55:02 -0400 | [diff] [blame] | 270 | } |