mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-01-27 06:35:22 +00:00
Merge pull request #6998 from aditya-deshpande-arm/fix-example-programs-usage
Fix incorrect dispatch to USAGE in example programs, which causes uninitialized memory to be used
This commit is contained in:
commit
94c9c96c94
4
ChangeLog.d/fix-example-programs-no-args.txt
Normal file
4
ChangeLog.d/fix-example-programs-no-args.txt
Normal file
@ -0,0 +1,4 @@
|
||||
Bugfix
|
||||
* Fix behavior of certain sample programs which could, when run with no
|
||||
arguments, access uninitialized memory in some cases. Fixes #6700 (which
|
||||
was found by TrustInSoft Analyzer during REDOCS'22) and #1120.
|
@ -169,7 +169,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
mbedtls_md_init(&md_ctx);
|
||||
|
||||
if (argc == 1) {
|
||||
if (argc < 2) {
|
||||
const int *list;
|
||||
|
||||
mbedtls_printf("print mode: generic_sum <mbedtls_md> <file> <file> ...\n");
|
||||
|
@ -71,7 +71,7 @@ int main(int argc, char **argv)
|
||||
mbedtls_ctr_drbg_init(&ctr_drbg);
|
||||
mbedtls_entropy_init(&entropy);
|
||||
|
||||
if (argc == 0) {
|
||||
if (argc < 2) {
|
||||
usage:
|
||||
mbedtls_printf(USAGE);
|
||||
goto exit;
|
||||
|
@ -200,7 +200,7 @@ int main(int argc, char *argv[])
|
||||
mbedtls_ctr_drbg_init(&ctr_drbg);
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
if (argc == 0) {
|
||||
if (argc < 2) {
|
||||
usage:
|
||||
mbedtls_printf(USAGE);
|
||||
#if defined(MBEDTLS_ECP_C)
|
||||
|
@ -103,7 +103,7 @@ int main(int argc, char *argv[])
|
||||
mbedtls_mpi_init(&D); mbedtls_mpi_init(&E); mbedtls_mpi_init(&DP);
|
||||
mbedtls_mpi_init(&DQ); mbedtls_mpi_init(&QP);
|
||||
|
||||
if (argc == 0) {
|
||||
if (argc < 2) {
|
||||
usage:
|
||||
mbedtls_printf(USAGE);
|
||||
goto cleanup;
|
||||
|
@ -220,7 +220,7 @@ int main(int argc, char *argv[])
|
||||
mbedtls_mpi_init(&D); mbedtls_mpi_init(&E); mbedtls_mpi_init(&DP);
|
||||
mbedtls_mpi_init(&DQ); mbedtls_mpi_init(&QP);
|
||||
|
||||
if (argc == 0) {
|
||||
if (argc < 2) {
|
||||
usage:
|
||||
mbedtls_printf(USAGE);
|
||||
goto exit;
|
||||
|
@ -867,7 +867,7 @@ int main(int argc, char *argv[])
|
||||
mbedtls_test_enable_insecure_external_rng();
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG */
|
||||
|
||||
if (argc == 0) {
|
||||
if (argc < 2) {
|
||||
usage:
|
||||
if (ret == 0) {
|
||||
ret = 1;
|
||||
|
@ -370,7 +370,7 @@ int main(int argc, char *argv[])
|
||||
mbedtls_pk_init(&pkey);
|
||||
mbedtls_ctr_drbg_init(&ctr_drbg);
|
||||
|
||||
if (argc == 0) {
|
||||
if (argc < 2) {
|
||||
usage:
|
||||
mbedtls_printf(USAGE);
|
||||
|
||||
|
@ -1633,7 +1633,7 @@ int main(int argc, char *argv[])
|
||||
signal(SIGINT, term_handler);
|
||||
#endif
|
||||
|
||||
if (argc == 0) {
|
||||
if (argc < 2) {
|
||||
usage:
|
||||
if (ret == 0) {
|
||||
ret = 1;
|
||||
|
@ -40,7 +40,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
|
||||
if (argc == 1 || strcmp(argv[1], "-h") == 0) {
|
||||
if (argc < 2 || strcmp(argv[1], "-h") == 0) {
|
||||
mbedtls_printf(USAGE, argv[0]);
|
||||
return MBEDTLS_EXIT_FAILURE;
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ int main(int argc, char *argv[])
|
||||
memset(buf, 0, sizeof(buf));
|
||||
memset(der_buffer, 0, sizeof(der_buffer));
|
||||
|
||||
if (argc == 0) {
|
||||
if (argc < 2) {
|
||||
usage:
|
||||
mbedtls_printf(USAGE);
|
||||
goto exit;
|
||||
|
@ -161,7 +161,7 @@ int main(int argc, char *argv[])
|
||||
memset(&cacrl, 0, sizeof(mbedtls_x509_crl));
|
||||
#endif
|
||||
|
||||
if (argc == 0) {
|
||||
if (argc < 2) {
|
||||
usage:
|
||||
mbedtls_printf(USAGE);
|
||||
goto exit;
|
||||
|
@ -159,7 +159,7 @@ int main(int argc, char *argv[])
|
||||
mbedtls_ctr_drbg_init(&ctr_drbg);
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
if (argc == 0) {
|
||||
if (argc < 2) {
|
||||
usage:
|
||||
mbedtls_printf(USAGE);
|
||||
goto exit;
|
||||
|
@ -329,7 +329,7 @@ int main(int argc, char *argv[])
|
||||
memset(buf, 0, sizeof(buf));
|
||||
memset(serial, 0, sizeof(serial));
|
||||
|
||||
if (argc == 0) {
|
||||
if (argc < 2) {
|
||||
usage:
|
||||
mbedtls_printf(USAGE);
|
||||
goto exit;
|
||||
|
@ -70,7 +70,7 @@ int main(int argc, char *argv[])
|
||||
*/
|
||||
mbedtls_x509_crl_init(&crl);
|
||||
|
||||
if (argc == 0) {
|
||||
if (argc < 2) {
|
||||
usage:
|
||||
mbedtls_printf(USAGE);
|
||||
goto exit;
|
||||
|
@ -70,7 +70,7 @@ int main(int argc, char *argv[])
|
||||
*/
|
||||
mbedtls_x509_csr_init(&csr);
|
||||
|
||||
if (argc == 0) {
|
||||
if (argc < 2) {
|
||||
usage:
|
||||
mbedtls_printf(USAGE);
|
||||
goto exit;
|
||||
|
Loading…
x
Reference in New Issue
Block a user