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

build fails with master at e5833c182cd05b15fe3450bc792abfe34e7e52dd #6308

Closed
devendranaga opened this issue Sep 21, 2022 · 2 comments · Fixed by #6325
Closed

build fails with master at e5833c182cd05b15fe3450bc792abfe34e7e52dd #6308

devendranaga opened this issue Sep 21, 2022 · 2 comments · Fixed by #6325
Labels
bug component-test Test framework and CI scripts size-s Estimated task size: small (~2d)

Comments

@devendranaga
Copy link

Summary

Build error with master at e5833c1

System information

Mbed TLS version (number or commit id): e5833c1
Operating system and version: Fedora 36
Configuration (if not default, please attach mbedtls_config.h):
Compiler and options (if you used a pre-built binary, please indicate how you obtained it):
Additional environment information:

Expected behavior

The build shall be clean. Looks like the test seem intended but one could set garbage data as initializer to silence the error.

Actual behavior

Steps to reproduce

  1. clone new repo.
  2. mkdir build.
  3. cd build.
  4. cmake ..
  5. make

Additional information

Below is the compiler error:

[ 65%] Building C object tests/CMakeFiles/test_suite_ecdh.dir/test_suite_ecdh.c.o
/home/devnaga/work/mbedtls/tests/suites/test_suite_ecdh.function: In function ‘test_ecdh_invalid_param’:
/home/devnaga/work/mbedtls/tests/suites/test_suite_ecdh.function:54:29: error: ‘kp’ may be used uninitialized [-Werror=maybe-uninitialized]
   54 |                             mbedtls_ecdh_get_params( &ctx, &kp,
      |                             ^~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/devnaga/work/mbedtls/tests/suites/test_suite_ecdh.function:2:
/home/devnaga/work/mbedtls/include/mbedtls/ecdh.h:347:5: note: by argument 2 of type ‘const mbedtls_ecp_keypair *’ to ‘mbedtls_ecdh_get_params’ declared here
  347 | int mbedtls_ecdh_get_params( mbedtls_ecdh_context *ctx,
      |     ^~~~~~~~~~~~~~~~~~~~~~~
/home/devnaga/work/mbedtls/tests/suites/test_suite_ecdh.function:50:25: note: ‘kp’ declared here
   50 |     mbedtls_ecp_keypair kp;
      |                         ^~
cc1: all warnings being treated as errors
make[2]: *** [tests/CMakeFiles/test_suite_ecdh.dir/build.make:86: tests/CMakeFiles/test_suite_ecdh.dir/test_suite_ecdh.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:3798: tests/CMakeFiles/test_suite_ecdh.dir/all] Error 2
@gabor-mezei-arm gabor-mezei-arm added bug size-s Estimated task size: small (~2d) component-test Test framework and CI scripts labels Sep 23, 2022
@gabor-mezei-arm
Copy link
Contributor

Thanks for reporting the bug.
It is reproducible even in the latest commit.

@devendranaga
Copy link
Author

I think there are multiple dependencies. For now i have used memset. But i think that's something you wouldn't want it in for invalid_param test. So there's a better fix IMO.

However, below is what i did:

diff --git a/tests/suites/test_suite_ecdh.function b/tests/suites/test_suite_ecdh.function
index e23b47199..bdc17f27d 100644
--- a/tests/suites/test_suite_ecdh.function
+++ b/tests/suites/test_suite_ecdh.function
@@ -50,6 +50,7 @@ void ecdh_invalid_param( )
     mbedtls_ecp_keypair kp;
     int invalid_side = 42;
 
+    memset(&kp, 0, sizeof(kp));
     TEST_EQUAL( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
                             mbedtls_ecdh_get_params( &ctx, &kp,
                                                      invalid_side ) );
diff --git a/tests/suites/test_suite_ecp.function b/tests/suites/test_suite_ecp.function
index 42d69b43a..d2083c4bd 100644
--- a/tests/suites/test_suite_ecp.function
+++ b/tests/suites/test_suite_ecp.function
@@ -72,6 +72,9 @@ void ecp_invalid_param( )
     size_t olen;
     unsigned char buf[42] = { 0 };
 
+    memset(&P, 0, sizeof(P));
+    memset(&grp, 0, sizeof(grp));
+
     TEST_EQUAL( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
                             mbedtls_ecp_point_write_binary( &grp, &P,
                                                       invalid_fmt,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug component-test Test framework and CI scripts size-s Estimated task size: small (~2d)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants