google/honggfuzz

_HF_DISASM_4_ARGS not reliable

ProkopRandacek opened this issue · 2 comments

Hi :D

It seems like the _HF_DISASM_4_ARGS macro is not being set when it should be.

cc -c -O3 -mtune=native -funroll-loops -std=c11 -I/usr/local/include -D_GNU_SOURCE -Wall -Wextra -Werror -Wno-format-truncation -Wno-override-init -I. -D_FILE_OFFSET_BITS=64 -finline-limit=4000 -D_HF_ARCH_LINUX  -o linux/bfd.o linux/bfd.c
linux/bfd.c: In function 'arch_bfdDisasm':
linux/bfd.c:231:5: error: too few arguments to function 'init_disassemble_info'
  231 |     init_disassemble_info(&info, instr, arch_bfdFPrintF);
      |     ^~~~~~~~~~~~~~~~~~~~~
In file included from linux/bfd.c:29:
/usr/include/dis-asm.h:480:13: note: declared here
  480 | extern void init_disassemble_info (struct disassemble_info *dinfo, void *stream,
      |             ^~~~~~~~~~~~~~~~~~~~~
make: *** [Makefile:263: linux/bfd.o] Error 1

I have binutils version 2.40-r5 installed from the alpine repository. There is no libcollector.h header bundled with this package, so the ifdef is not being triggered.

appending -D_HF_DISASM_4_ARGS to CFLAGS does fix the issue but I don't really know how to fix the ifdef itself :/

I spent a few h on this, and couldn't find 100% bullet-proof solution. There's like 3 months of time (in terms of library's dev lifetime), during which it's impossible to figure out whether the API takes 3 or 4 args. Apparently the libdisasm API is not meant to be stable.

Please try with 37e8e81 - I hope the 4th arg will be discarded with all known CPU archs correctly, but I have a feeling it's not 100% guaranteed.

Hi. sorry for the delay.

37e8e813 works on my machine as far as I can tell.

thanks! :D