Skip to content

Commit

Permalink
Remove unused inject_hash_no_write parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
justsmth committed Aug 23, 2024
1 parent 6f8eeb1 commit 1f846c5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
3 changes: 2 additions & 1 deletion util/fipstools/inject_hash/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 9 additions & 10 deletions util/fipstools/inject_hash/inject_hash_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = {
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down
11 changes: 7 additions & 4 deletions util/fipstools/inject_hash/tests/inject_hash_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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) {
Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 1f846c5

Please sign in to comment.