Skip to content
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

FAPI: Fix segfault if json field is null. #2880

Merged

Conversation

JuergenReppSIT
Copy link
Member

The function json_object_object_get_ex does not create a json object for the parameter value in the case "key":null. This caused a segfault in json deserialization.
Fixes: #2878

The function json_object_object_get_ex does not create a
json object for the parameter value in the case "key":null.
This caused a segfault in json deserialization.
Fixes: tpm2-software#2878

Signed-off-by: Juergen Repp <juergen_repp@web.de>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (*sub_jso) {
    return true;
} else {
    return false;
}

could be simplified to:

return (*sub_jso);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could give some static code analysis alarms.

return !!(*sub_jso);

might however work.
But I also don't mind the explicit version.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice solution return !!(*sub_jso); but i would prefer the explicit version. @AndreasFuchsTPM could you please approve the PR.

@AndreasFuchsTPM AndreasFuchsTPM merged commit d9d91df into tpm2-software:master Aug 13, 2024
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fapi_Import crashes with SIGSEGV when importing a policy that contains "null" element
3 participants