rnpgp / rnp

RNP: high performance C++ OpenPGP library used by Mozilla Thunderbird
https://www.rnpgp.org
Other
192 stars 54 forks source link

Coverity CID 1428747: Memory - illegal accesses (USE_AFTER_FREE) #1246

Open ronaldtse opened 3 years ago

ronaldtse commented 3 years ago
** CID 1428747:  Memory - illegal accesses  (USE_AFTER_FREE)
/src/tests/ffi.cpp: 8334 in rnp_tests_test_ffi_export_revocation_Test::TestBody()()

________________________________________________________________________________________________________
*** CID 1428747:  Memory - illegal accesses  (USE_AFTER_FREE)
/src/tests/ffi.cpp: 8334 in rnp_tests_test_ffi_export_revocation_Test::TestBody()()
8328         assert_rnp_success(rnp_key_export_revocation(key_handle, output, 0, "SHA256", NULL, NULL));
8329         assert_rnp_success(rnp_output_destroy(output));
8330         assert_rnp_success(rnp_output_to_path(&output, "alice-revocation.pgp"));
8331         /* correct password provider - must succeed */
8332         assert_rnp_success(rnp_key_lock(key_handle));
8333         assert_rnp_success(rnp_ffi_set_pass_provider(ffi, getpasscb, (void *) "password"));
   CID 1428747:  Memory - illegal accesses  (USE_AFTER_FREE)
   Passing freed pointer "output" as an argument to "rnp_key_export_revocation".
8334         assert_rnp_success(rnp_key_export_revocation(
8335           key_handle, output, 0, "SHA256", "superseded", "test key revocation"));
8336         /* make sure FFI locks key back */
8337         bool locked = false;
8338         assert_rnp_success(rnp_key_is_locked(key_handle, &locked));
8339         assert_true(locked);
ni4 commented 3 years ago

This is actually about tests, we have a lot of issues like this. What about totally disabling analysis for tests folder? CC @ronaldtse @dewyatt

ni4 commented 1 year ago

While tests sources are marked as ignored for a while, Coverity still seem to analyze those and include into overall density calculations. Not sure what else could be done to display shiny green badge.

Screenshot 2023-03-31 at 14 06 57

Screenshot 2023-03-31 at 14 08 29