diff --git a/util/fipstools/inject_hash/common.h b/util/fipstools/inject_hash/common.h index f2501e2a12..4954c32f5f 100644 --- a/util/fipstools/inject_hash/common.h +++ b/util/fipstools/inject_hash/common.h @@ -18,7 +18,8 @@ extern "C" fprintf(stderr, "\n"); \ } while(0) -int inject_hash_no_write(const char *ar_input, const char *o_input, const char *out_path, int apple_flag, uint8_t **object_bytes, size_t *object_bytes_size); +int inject_hash_no_write(const char *o_input, int apple_flag, + uint8_t **object_bytes, size_t *object_bytes_size); int inject_hash(int argc, char *argv[]); #ifdef __cplusplus diff --git a/util/fipstools/inject_hash/inject_hash_lib.c b/util/fipstools/inject_hash/inject_hash_lib.c index d1524fb3c5..c6ed41fad2 100644 --- a/util/fipstools/inject_hash/inject_hash_lib.c +++ b/util/fipstools/inject_hash/inject_hash_lib.c @@ -189,7 +189,8 @@ static int do_apple(const char *object_file, uint8_t **text_module, size_t *text return ret; } -int inject_hash_no_write(const char *ar_input, const char *o_input, const char *out_path, int apple_flag, uint8_t **object_bytes, size_t *object_bytes_size) { +int inject_hash_no_write(const char *o_input, int apple_flag, + uint8_t **object_bytes, size_t *object_bytes_size) { int ret = 0; uint8_t uninit_hash[] = { @@ -209,14 +210,11 @@ int inject_hash_no_write(const char *ar_input, const char *o_input, const char * uint32_t hash_index; - if (ar_input != NULL) { - // TODO: work with an archive, not needed for Apple platforms - } else { - *object_bytes = read_object(o_input, object_bytes_size); - if (object_bytes == NULL) { - LOG_ERROR("Error reading object bytes from %s", o_input); - goto end; - } + + *object_bytes = read_object(o_input, object_bytes_size); + if (object_bytes == NULL) { + LOG_ERROR("Error reading object bytes from %s", o_input); + goto end; } if (apple_flag == 1) { @@ -339,7 +337,8 @@ int inject_hash(int argc, char *argv[]) { goto end; } - if (!inject_hash_no_write(ar_input, o_input, out_path, apple_flag, &object_bytes, &object_bytes_size)) { + if (!inject_hash_no_write(o_input, apple_flag, &object_bytes, + &object_bytes_size)) { LOG_ERROR("Error encountered while injecting hash"); goto end; } diff --git a/util/fipstools/inject_hash/tests/inject_hash_tests.cc b/util/fipstools/inject_hash/tests/inject_hash_tests.cc index d08f40f2fe..6a53ddb28c 100644 --- a/util/fipstools/inject_hash/tests/inject_hash_tests.cc +++ b/util/fipstools/inject_hash/tests/inject_hash_tests.cc @@ -8,7 +8,8 @@ #include "../common.h" - +// Paths below are based on expected location of library artifacts relative +// to the location of this test executable. // TODO: change this based on platform, we only care about Apple for now #define GOOD_LIB_NAME "test_libs/libgood_lib.dylib" #define BAD_HASH_LIB_NAME "test_libs/libbad_hash_lib.dylib" @@ -27,7 +28,7 @@ TEST_F(InjectHashTestFixture, TestGoodLib) { uint8_t *object_bytes_ptr = object_bytes.get(); - ASSERT_EQ(1, inject_hash_no_write(NULL, good_lib_filename.c_str(), good_lib_filename.c_str(), 1, &object_bytes_ptr, &object_bytes_size)); + ASSERT_EQ(1, inject_hash_no_write(good_lib_filename.c_str(), 1, &object_bytes_ptr, &object_bytes_size)); } TEST_F(InjectHashTestFixture, TestBadHashLib) { @@ -39,7 +40,8 @@ TEST_F(InjectHashTestFixture, TestBadHashLib) { int inject_hash_ret; testing::internal::CaptureStderr(); - inject_hash_ret = inject_hash_no_write(NULL, bad_hash_lib_filename.c_str(), bad_hash_lib_filename.c_str(), 1, &object_bytes_ptr, &object_bytes_size); + inject_hash_ret = inject_hash_no_write(bad_hash_lib_filename.c_str(), 1, + &object_bytes_ptr, &object_bytes_size); std::string captured_stderr = testing::internal::GetCapturedStderr(); ASSERT_EQ(0, inject_hash_ret); @@ -55,7 +57,8 @@ TEST_F(InjectHashTestFixture, TestBadMarkerLib) { int inject_hash_ret; testing::internal::CaptureStderr(); - inject_hash_ret = inject_hash_no_write(NULL, bad_marker_lib_filename.c_str(), bad_marker_lib_filename.c_str(), 1, &object_bytes_ptr, &object_bytes_size); + inject_hash_ret = inject_hash_no_write(bad_marker_lib_filename.c_str(), 1, + &object_bytes_ptr, &object_bytes_size); std::string captured_stderr = testing::internal::GetCapturedStderr(); ASSERT_EQ(0, inject_hash_ret);