New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve robustness of XmlTreeLib #458
base: release/202311
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -877,14 +877,15 @@ BuildNodeList ( | |
// | ||
Status = RtlXmlNextToken (&State, &Next, FALSE); | ||
if (EFI_ERROR (Status)) { | ||
DEBUG ((EFI_D_ERROR, "Failed to get the next token, Status = 0x%x\n", Status)); | ||
DEBUG ((EFI_D_ERROR, "Failed to get the next token, Status = %r\n", Status)); // MS_CHANGE | ||
goto Exit; | ||
} else if (Next.fError) { | ||
// | ||
// Errors in parse, such as bad characters, come out here in the | ||
// fError member | ||
// | ||
DEBUG ((EFI_D_ERROR, "Error during tokenization, Status = 0x%x\n", Next.fError)); | ||
DEBUG ((EFI_D_ERROR, "Error during tokenization, Next.fError = %d\n", Next.fError)); // MS_CHANGE | ||
Status = EFI_ABORTED; // MS_CHANGE | ||
goto Exit; | ||
} | ||
|
||
|
@@ -1071,7 +1072,7 @@ BuildNodeList ( | |
// | ||
Status = AddAttributeToNode (CurrentNode, AttributeName, AttributeValue); | ||
if (EFI_ERROR (Status)) { | ||
DEBUG ((EFI_D_ERROR, "ERROR: AddAttributeToNode() failed, Status = 0x%x\n", Status)); | ||
DEBUG ((EFI_D_ERROR, "ERROR: AddAttributeToNode() failed, Status = %r\n", Status)); // MS_CHANGE | ||
goto Exit; | ||
} | ||
} else if (Next.State == XTSS_ENDELEMENT_NAME) { | ||
|
@@ -1105,6 +1106,20 @@ BuildNodeList ( | |
// | ||
if (CurrentNode) { | ||
CurrentNode = CurrentNode->ParentNode; | ||
// MS_CHANGE [begin] | ||
// | ||
// Topmost node, ignore tailing characters | ||
// | ||
// DONE-CCC: | ||
// See also, TODO-AAA and TODO-BBB in `xml_fasterxml.c` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's leave full comments, please don't use annotations like DONE-CCC or TODO-AAA. |
||
// | ||
DEBUG ((DEBUG_VERBOSE, "New CurrentNode, %p\n", CurrentNode)); | ||
if (CurrentNode == NULL) { | ||
DEBUG ((DEBUG_VERBOSE, "At the end of the Root node\n")); | ||
break; | ||
} | ||
|
||
// MS_CHANGE [end] | ||
} | ||
} else if (Next.State == XTSS_ELEMENT_CLOSE_EMPTY) { | ||
DEBUG ((DEBUG_VERBOSE, "XTSS_ELEMENT_CLOSE_EMPTY, empty close\n")); | ||
|
@@ -1115,6 +1130,19 @@ BuildNodeList ( | |
// | ||
if (CurrentNode) { | ||
CurrentNode = CurrentNode->ParentNode; | ||
DEBUG ((DEBUG_VERBOSE, "New CurrentNode, %p\n", CurrentNode)); | ||
|
||
// MS_CHANGE [begin] | ||
// | ||
// DONE-CCC-2: | ||
// | ||
DEBUG ((DEBUG_VERBOSE, "New CurrentNode, %p\n", CurrentNode)); | ||
if (CurrentNode == NULL) { | ||
DEBUG ((DEBUG_VERBOSE, "At the end of the Root node\n")); | ||
break; | ||
} | ||
|
||
// MS_CHANGE [end] | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2700,6 +2700,22 @@ RtlXmlNextToken ( | |
pToken->fError = TRUE; | ||
return success; | ||
} | ||
// MS_CHANGE | ||
// | ||
// TODO-BBB: See TODO-AAA | ||
// | ||
// if (pRawToken->TokenName == NTXML_RAWTOKEN_ERROR) { | ||
// pToken->fError = TRUE; | ||
// success = EFI_ABORTED; | ||
// return success; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of commenting out the code, we can remove it. If it is helpful, do leave a full comment explaining why we don't check if the TokenName == NTXML_RAWTOKEN_ERROR. |
||
// } | ||
// | ||
// Why TODO? | ||
// If we turn on this, we will be endless on other place.. | ||
// | ||
// Work around? | ||
// See DONE-CCC in `XmlTreeLib.c` | ||
// | ||
|
||
cbTotalTokenLength = pRawToken->Run.cbData; | ||
|
||
|
@@ -2946,6 +2962,14 @@ RtlXmlNextToken ( | |
|
||
cbTotalTokenLength = pRawToken->Run.cbData; | ||
|
||
// MS_CHANGE | ||
// | ||
// TODO-AAA: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this TODO fixable now? |
||
// if we encounter a NTXML_RAWTOKEN_ERROR, | ||
// we will run into endless XTSS_STREAM_HYPERSPACE | ||
// | ||
// DEBUG ((DEBUG_VERBOSE, "pRawToken->TokenName = %d\n", pRawToken->TokenName)); | ||
|
||
NextState = XTSS_STREAM_HYPERSPACE; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
MS_CHANGE
tags aren't needed for the mu_plus repo (since this entire repo represents mu value adds). For future reference,MU_CHANGE
is preferred for repos that do have upstream components that we track changes against.