Fix format strings
brianrho opened this issue · 2 comments
brianrho commented
The DEBUG build yields these warnings:
- In
hook.c
:
../loadlibrary/intercept/hook.c: In function ‘insert_function_redirect’:
../loadlibrary/intercept/hook.c:135:16: warning: too many arguments for format [-Wformat-extra-args]
135 | printf("mprotect() failed on stub => %m, try `sudo setenforce 0`\n", fixup);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Suggested fix:
- printf("mprotect() failed on stub => %m, try `sudo setenforce 0`\n", fixup);
+ printf("mprotect() failed on stub => %p (%m), try `sudo setenforce 0`\n", fixup);
- In
pe_linker.c
:
pe_linker.c: In function ‘fix_pe_image’:
pe_linker.c:64:32: warning: format ‘%p’ expects argument of type ‘void *’, but argument 6 has type ‘DWORD’ {aka ‘unsigned int’} [-Wformat=]
64 | #define ERROR(fmt, ...) printf("%s (%s:%d): " fmt "\n", \
| ^~~~~~~~~~~~~~
......
478 | ERROR("failed to mmap desired space for image: %d bytes, image base %p, %m", image_size, pe->opt_hdr->ImageBase);
| ~~~~~~~~~~~~~~~~~~~~~~
| |
| DWORD {aka unsigned int}
pe_linker.c:478:17: note: in expansion of macro ‘ERROR’
478 | ERROR("failed to mmap desired space for image: %d bytes, image base %p, %m", image_size, pe->opt_hdr->ImageBase);
| ^~~~~
pe_linker.c:478:86: note: format string is defined here
478 | ERROR("failed to mmap desired space for image: %d bytes, image base %p, %m", image_size, pe->opt_hdr->ImageBase);
| ~^
| |
| void *
| %d
Suggested fix:
- ERROR("failed to mmap desired space for image: %d bytes, image base %p, %m", image_size, pe->opt_hdr->ImageBase);
+ ERROR("failed to mmap desired space for image: %d bytes, image base %x, %m", image_size, pe->opt_hdr->ImageBase);
Thanks.
taviso commented
Huh, not sure how I missed that - Thanks!