-
Notifications
You must be signed in to change notification settings - Fork 26
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
Add NULL Check to allow IpmiSendCommandInternal flow through avoinding assert as routine does not consider NULL para… #243
base: main
Are you sure you want to change the base?
Conversation
…meter for ResponseData and ResponseDataSize Parameter Current Behavior: IpmiSendCommandInternal does not consider NULL parameter for ResponseData and ResponseDataSize Parameter Expected Behavior: NULL can be passed as parameter for IN OUT UINT8 *ResponseData, IN OUT UINT8 *ResponseDataSize in IpmiSendCommandInternal Routine FIX APPLIED: Add NULL Check as IpmiSendCommandInternal does not consider NULL parameter for ResponseData and ResponseDataSize Parameter
Could you update the title to indicate this is allowing for a null instance of the response on a send? Right now its unclear if you are adding a check to prevent or allow this. |
@@ -277,7 +277,7 @@ IpmiSendCommandInternal ( | |||
// | |||
// Verify the response data buffer passed in is big enough. | |||
// | |||
if ((DataSize - IPMI_RESPONSE_HEADER_SIZE) > *ResponseDataSize) { | |||
if ((ResponseDataSize != NULL) && (DataSize - IPMI_RESPONSE_HEADER_SIZE) > *ResponseDataSize){ |
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.
I would have a check at the beginning that will return invalid parameter if (ResponseDataSize == NULL) != (ResponseData)
Then you can just put this whole block under a (ResponseData != NULL)
check instead of two different checks.
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.
Checking at the beginning and return Invalid parameter will return right at the start of the routine.
There are some valid commands that can have NULL for ResponseDataSize & Response Data but still want to send command to BMC.
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.
Sure, but my point is that a caller should never pass NULL for one of those but not the other. Adding that check before doing any work would have clarify the behavior of this functionas well as allow you to clean up and centralize these checks. specifically, (ResponseDataSize == NULL) != (ResponseData == NULL)
(which i realize i didn't write correctly the first time)
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.
Hi Chris,
I have made changes in function header routine in both c & .h files as below:
IN OUT UINT8 *ResponseData OPTIONAL,
IN OUT UINT8 *ResponseDataSize OPTIONAL
For your comment for the check, still I am unsure why it required to be at the early and a centralised check.
Even though these 2 passed arguments are a pointer of a data and its size, they both are 2 different entities passed as pointer for the routine. Being an optional parameter, the check is being made only when is being used and is not interdependent on each other. That is the way code has been modified.
By this way it takes care of cases: Both parameters are NULL, Both parameters are NOT NULL and one of the parameter is NULL.
Early check and breaking with a return would still will not execute the required code in NULL passed with intentionally required,
Do clarify me on if I am not missing any case that you are foreseeing.
for (Index = 1; Index < *ResponseDataSize; Index++) { | ||
ResponseData[*ResponseDataSize - Index] = ResponseData[*ResponseDataSize - (Index + 1)]; | ||
} | ||
if (ResponseData != NULL && ResponseDataSize != NULL) { |
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.
Need to update the header here and in the .h file to add the OPTIONAL
note for ResponseData and ResponseDataSize
Modified the Title |
@microsoft-github-policy-service agree company="AMI" |
Description
Add NULL Check as IpmiSendCommandInternal does not consider NULL parameter for ResponseData and ResponseDataSize Parameter
Current Behavior:
IpmiSendCommandInternal does not consider NULL parameter for ResponseData and ResponseDataSize Parameter
Expected Behavior:
NULL can be passed as parameter for
IN OUT UINT8 *ResponseData,
IN OUT UINT8 *ResponseDataSize
in IpmiSendCommandInternal Routine
FIX APPLIED:
Add NULL Check as IpmiSendCommandInternal does not consider NULL parameter for ResponseData and ResponseDataSize Parameter
flow, or firmware?
validation improvement, ...
in build or boot behavior?
a function in a new library class in a pre-existing module, ...
outside direct code modifications (and comments)?
on an a separate Web page, ...
How This Was Tested
IpmiRasStartToDisableBmcRas command was issued with NULL parameter for ResponseData and ResponseDataSIze.
WithoutFIx, cpu exception is observed and with Fix, IPMI send Command can proceed.
Integration Instructions
N/A