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

[Backport 2.28] Fix incorrect dispatch to USAGE in example programs, which causes uninitialized memory to be used #7026

Conversation

aditya-deshpande-arm
Copy link
Contributor

@aditya-deshpande-arm aditya-deshpande-arm commented Feb 2, 2023

Description

Fixes issues #1120 and #6700.

Numerous example programs contain the following:

if (argc == 0) {
    goto USAGE;
}

// later in program
p = argv[1];

If a program is called from the shell thenargc = 1, so the program will not go to USAGE due to the check. The access to argv[1] is accessing undefined memory. This PR changes the check to if (argc < 2).

Gatekeeper checklist

daverodgman
daverodgman previously approved these changes Feb 2, 2023
Copy link
Contributor

@daverodgman daverodgman left a comment

Choose a reason for hiding this comment

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

LGTM

Signed-off-by: Aditya Deshpande <[email protected]>
@aditya-deshpande-arm aditya-deshpande-arm force-pushed the backport-fix-example-programs-usage branch from f9ea38f to 56d9003 Compare February 5, 2023 15:48
Copy link
Contributor

@tom-cosgrove-arm tom-cosgrove-arm left a comment

Choose a reason for hiding this comment

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

LGTM

@daverodgman daverodgman merged commit 9f63cb7 into Mbed-TLS:mbedtls-2.28 Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-ci Needs to pass CI tests needs-review Every commit must be reviewed by at least two team members,
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants