Describe the bug
Running OpenWRT's uhttpd (uhttpd: ELF 32-bit MSB executable, MIPS, MIPS32 version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-mips-sf.so.1, no section header) the bind syscall will fail because sin_family is unpacked as little endian, even though it's encoded in big endian.
The example file is attached as uhttpd.zip.
Sample Code/Sample fix
def ql_syscall_bind(ql, bind_fd, bind_addr, bind_addrlen, *args, **kw):
regreturn = 0
if ql.archtype== QL_ARCH.X8664:
data = ql.mem.read(bind_addr, 8)
else:
data = ql.mem.read(bind_addr, bind_addrlen)
# Works
sin_family, = struct.unpack(">h", data[:2])
# Doesn't work
# sin_family, = struct.unpack("<h", data[:2])
I am unsure how to solve this, as I assume this works on other architectures? What's the "qiling way" of handling unpacks for different endianess?
Describe the bug
Running OpenWRT's uhttpd (
uhttpd: ELF 32-bit MSB executable, MIPS, MIPS32 version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-mips-sf.so.1, no section header) the bind syscall will fail because sin_family is unpacked as little endian, even though it's encoded in big endian.The example file is attached as uhttpd.zip.
Sample Code/Sample fix
I am unsure how to solve this, as I assume this works on other architectures? What's the "qiling way" of handling unpacks for different endianess?