提交 4ad7a1c7 编写于 作者: V vit9696

Rename Base64Decode to OcBase64Decode and fix its prototype to be close to EDK2 for later migration

上级 6511ba6b
......@@ -25,6 +25,8 @@ typedef struct {
// Base64Decode
/**
TODO: edk2 now has its implementation in BaseLib, review it and use once it appears in UDK.
@param[in] EncodedData A pointer to the data to convert.
@param[in] EncodedLength The length of data to convert.
@param[in] DecodedData A pointer to location to store the decoded data.
......@@ -32,8 +34,9 @@ typedef struct {
@retval TRUE on success.
**/
BOOLEAN
Base64Decode (
RETURN_STATUS
EFIAPI
OcBase64Decode (
IN CONST CHAR8 *EncodedData,
IN UINTN EncodedLength,
OUT UINT8 *DecodedData,
......
......@@ -50,8 +50,9 @@ STATIC CONST UINT8 D[] = {
66,66,66,66,66,66
};
BOOLEAN
Base64Decode (
RETURN_STATUS
EFIAPI
OcBase64Decode (
IN CONST CHAR8 *EncodedData,
IN UINTN EncodedLength,
OUT UINT8 *DecodedData,
......@@ -70,7 +71,7 @@ Base64Decode (
case WHITESPACE:
continue; /* skip whitespace */
case INVALID:
return FALSE; /* invalid input, return error */
return RETURN_INVALID_PARAMETER; /* invalid input, return error */
case EQUALS: /* pad character, end of data */
EncodedData = End;
continue;
......@@ -79,7 +80,7 @@ Base64Decode (
Iter++; /* increment the number of iteration */
/* If the buffer is full, split it into bytes */
if (Iter == 4) {
if ((Len += 3) > *DecodedLength) return FALSE; /* buffer overflow */
if ((Len += 3) > *DecodedLength) return RETURN_BUFFER_TOO_SMALL; /* buffer overflow */
*(DecodedData++) = (Buf >> 16U) & 255U;
*(DecodedData++) = (Buf >> 8U) & 255U;
*(DecodedData++) = Buf & 255U;
......@@ -89,14 +90,14 @@ Base64Decode (
}
if (Iter == 3) {
if ((Len += 2) > *DecodedLength) return FALSE; /* buffer overflow */
if ((Len += 2) > *DecodedLength) return RETURN_BUFFER_TOO_SMALL; /* buffer overflow */
*(DecodedData++) = (Buf >> 10U) & 255U;
*(DecodedData++) = (Buf >> 2U) & 255U;
} else if (Iter == 2) {
if (++Len > *DecodedLength) return FALSE; /* buffer overflow */
if (++Len > *DecodedLength) return RETURN_BUFFER_TOO_SMALL; /* buffer overflow */
*(DecodedData++) = (Buf >> 4U) & 255U;
}
*DecodedLength = Len; /* modify to reflect the actual output size */
return TRUE;
return EFI_SUCCESS;
}
......@@ -1099,9 +1099,9 @@ PlistDataValue (
UINT32 *Size
)
{
CONST CHAR8 *Content;
UINTN Length;
BOOLEAN Result;
CONST CHAR8 *Content;
UINTN Length;
RETURN_STATUS Result;
if (PlistNodeCast (Node, PLIST_NODE_TYPE_DATA) == NULL) {
return FALSE;
......@@ -1114,9 +1114,9 @@ PlistDataValue (
}
Length = *Size;
Result = Base64Decode (Content, AsciiStrLen (Content), Buffer, &Length);
Result = OcBase64Decode (Content, AsciiStrLen (Content), Buffer, &Length);
if (Result && (UINT32) Length == Length) {
if (!RETURN_ERROR (Result) && (UINT32) Length == Length) {
*Size = (UINT32) Length;
return TRUE;
}
......@@ -1184,16 +1184,16 @@ PlistMetaDataValue (
UINT32 *Size
)
{
CONST CHAR8 *Content;
UINTN Length;
BOOLEAN Result;
CONST CHAR8 *Content;
UINTN Length;
RETURN_STATUS Result;
if (PlistNodeCast (Node, PLIST_NODE_TYPE_DATA) != NULL) {
Content = XmlNodeContent (Node);
if (Content != NULL) {
Result = Base64Decode (Content, AsciiStrLen (Content), Buffer, &Length);
Result = OcBase64Decode (Content, AsciiStrLen (Content), Buffer, &Length);
if (Result && (UINT32) Length == Length) {
if (!RETURN_ERROR (Result) && (UINT32) Length == Length) {
*Size = (UINT32) Length;
} else {
return FALSE;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册