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

Side by Side Diff: core/src/fpdfapi/fpdf_parser/fpdf_parser_encrypt.cpp

Issue 382603003: Fix uninitialized okeybuf (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 6 years, 5 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 <time.h> 7 #include <time.h>
8 #include "../../../include/fpdfapi/fpdf_parser.h" 8 #include "../../../include/fpdfapi/fpdf_parser.h"
9 #include "../../../include/fdrm/fx_crypt.h" 9 #include "../../../include/fdrm/fx_crypt.h"
10 const FX_BYTE defpasscode[32] = { 10 const FX_BYTE defpasscode[32] = {
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 FX_DWORD copy_len = key_len; 453 FX_DWORD copy_len = key_len;
454 if (copy_len > sizeof(digest)) { 454 if (copy_len > sizeof(digest)) {
455 copy_len = sizeof(digest); 455 copy_len = sizeof(digest);
456 } 456 }
457 FXSYS_memcpy32(enckey, digest, copy_len); 457 FXSYS_memcpy32(enckey, digest, copy_len);
458 int okeylen = okey.GetLength(); 458 int okeylen = okey.GetLength();
459 if (okeylen > 32) { 459 if (okeylen > 32) {
460 okeylen = 32; 460 okeylen = 32;
461 } 461 }
462 FX_BYTE okeybuf[64]; 462 FX_BYTE okeybuf[64];
463 FXSYS_memset32(okeybuf, 0, sizeof(okeybuf));
463 FXSYS_memcpy32(okeybuf, (FX_LPCSTR)okey, okeylen); 464 FXSYS_memcpy32(okeybuf, (FX_LPCSTR)okey, okeylen);
464 if (m_Revision == 2) { 465 if (m_Revision == 2) {
465 CRYPT_ArcFourCryptBlock(okeybuf, okeylen, enckey, key_len); 466 CRYPT_ArcFourCryptBlock(okeybuf, okeylen, enckey, key_len);
466 } else { 467 } else {
467 for (int i = 19; i >= 0; i --) { 468 for (int i = 19; i >= 0; i --) {
468 FX_BYTE tempkey[32]; 469 FX_BYTE tempkey[32];
469 for (int j = 0; j < m_KeyLen; j ++) { 470 for (int j = 0; j < m_KeyLen; j ++) {
470 tempkey[j] = enckey[j] ^ i; 471 tempkey[j] = enckey[j] ^ i;
471 } 472 }
472 CRYPT_ArcFourCryptBlock(okeybuf, okeylen, tempkey, key_len); 473 CRYPT_ArcFourCryptBlock(okeybuf, okeylen, tempkey, key_len);
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 m_pAESContext = NULL; 949 m_pAESContext = NULL;
949 m_Cipher = FXCIPHER_NONE; 950 m_Cipher = FXCIPHER_NONE;
950 m_KeyLen = 0; 951 m_KeyLen = 0;
951 } 952 }
952 CPDF_StandardCryptoHandler::~CPDF_StandardCryptoHandler() 953 CPDF_StandardCryptoHandler::~CPDF_StandardCryptoHandler()
953 { 954 {
954 if (m_pAESContext) { 955 if (m_pAESContext) {
955 FX_Free(m_pAESContext); 956 FX_Free(m_pAESContext);
956 } 957 }
957 } 958 }
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