Skip to content

Commit

Permalink
CryptoPkg: Fix the dereferenced pointer issue
Browse files Browse the repository at this point in the history
This patch is to fix one dereferenced pointer issue in new
Pkcs7GetAttachedContent API, and add the memory allocation
failure check.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qin Long <[email protected]>
Reviewed-by: Ye Ting <[email protected]>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17731 6f19259b-4bc3-4df7-8a09-765794883524
  • Loading branch information
Qin Long authored and qlong committed Jun 30, 2015
1 parent e75390f commit 2aabd14
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7Verify.c
Original file line number Diff line number Diff line change
Expand Up @@ -719,18 +719,18 @@ Pkcs7GetAttachedContent (
CONST UINT8 *Temp;
ASN1_OCTET_STRING *OctStr;

*Content = NULL;
Pkcs7 = NULL;
SignedData = NULL;
OctStr = NULL;

//
// Check input parameter.
//
if ((P7Data == NULL) || (P7Length > INT_MAX) || (Content == NULL) || (ContentSize == NULL)) {
return FALSE;
}

*Content = NULL;
Pkcs7 = NULL;
SignedData = NULL;
OctStr = NULL;

Status = WrapPkcs7Data (P7Data, P7Length, &Wrapped, &SignedData, &SignedDataSize);
if (!Status || (SignedDataSize > INT_MAX)) {
goto _Exit;
Expand Down Expand Up @@ -771,6 +771,10 @@ Pkcs7GetAttachedContent (
if ((OctStr->length > 0) && (OctStr->data != NULL)) {
*ContentSize = OctStr->length;
*Content = malloc (*ContentSize);
if (*Content == NULL) {
*ContentSize = 0;
goto _Exit;
}
CopyMem (*Content, OctStr->data, *ContentSize);
}
}
Expand Down

0 comments on commit 2aabd14

Please sign in to comment.