On 01.04.2025 15:08, Roger Pau Monne wrote:
> @@ -83,6 +111,31 @@ static unsigned int load(const char *name, int *handle,
> exit(3);
> }
>
> + if ( !string_table && pe_hdr.symbol_table )
> + {
> + char *strings;
> +
> + if ( lseek(in, pe_hdr.symbol_table + pe_hdr.symbols * SYM_SIZE,
> + SEEK_SET) < 0 ||
> + read(in, &string_table_size, sizeof(string_table_size)) !=
> + sizeof(string_table_size) )
> + {
> + perror(name);
> + exit(3);
> + }
> +
> + string_table_size -= sizeof(string_table_size);
> + strings = malloc(string_table_size);
One more thing: Perhaps better to allocate an extra byte here, ...
> + if ( read(in, strings, string_table_size) != string_table_size )
> + {
> + perror(name);
> + exit(3);
> + }
> +
> + string_table = strings;
> + }
... and then put a nul terminator at the end, just in case.
Jan