Skip to content

Commit

Permalink
use size_t where appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill Yang authored and billbo-yang committed Apr 15, 2024
1 parent d9e3234 commit a9a1d4c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions util/fipstools/inject_hash/macho_parser/macho_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ int read_macho_file(const char *filename, machofile *macho) {
int symtab_found = 0;

// mach-o/loader.h explains that cmdsize (and by extension sizeofcmds) must be a multiple of 8 on 64-bit systems. struct load_command will always be 8 bytes.
for (uint32_t i = 0; i < macho->macho_header.sizeofcmds / sizeof(struct load_command); i += load_commands[i].cmdsize / sizeof(struct load_command)) {
for (size_t i = 0; i < macho->macho_header.sizeofcmds / sizeof(struct load_command); i += load_commands[i].cmdsize / sizeof(struct load_command)) {
if (load_commands[i].cmd == LC_SEGMENT_64) {
struct segment_command_64 *segment = (struct segment_command_64 *)&load_commands[i];
if (strcmp(segment->segname, "__TEXT") == 0) {
struct section_64 *sections = (struct section_64 *)&segment[1];
for (uint32_t j = 0; j < segment->nsects; j++) {
for (size_t j = 0; j < segment->nsects; j++) {
if (strcmp(sections[j].sectname, "__text") == 0) {
if (text_found == 1) {
LOG_ERROR("Duplicate __text section found");
Expand Down Expand Up @@ -191,8 +191,8 @@ uint32_t find_macho_symbol_index(uint8_t *symbol_table_data, size_t symbol_table
memcpy(string_table, string_table_data, string_table_size);

int found = 0;
uint32_t index = 0;
for (uint32_t i = 0; i < symbol_table_size / sizeof(struct nlist_64); i++) {
size_t index = 0;
for (size_t i = 0; i < symbol_table_size / sizeof(struct nlist_64); i++) {
struct nlist_64 *symbol = (struct nlist_64 *)(symbol_table_data + i * sizeof(struct nlist_64));
if (strcmp(symbol_name, &string_table[symbol->n_un.n_strx]) == 0) {
if (found == 0) {
Expand Down

0 comments on commit a9a1d4c

Please sign in to comment.