We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
*Describe the bug readv() according to the manpages should return the number of bytes read but it seems to return the size of the iovec everytime???
readv()
Sample Code
def ql_syscall_readv(ql: Qiling, fd: int, vec: int, vlen: int): regreturn = 0 size_t_len = ql.arch.pointersize iov = ql.mem.read(vec, vlen * size_t_len * 2) ql.log.debug('readv() CONTENT:') for i in range(vlen): addr = ql.unpack(iov[i * size_t_len * 2 : i * size_t_len * 2 + size_t_len]) l = ql.unpack(iov[i * size_t_len * 2 + size_t_len : i * size_t_len * 2 + size_t_len * 2]) regreturn += l if hasattr(ql.os.fd[fd], 'read'): data = ql.os.fd[fd].read(l) ql.log.debug(f'{data!r}') ql.mem.write(addr, data) return regreturn
Expected behavior readv() should return the amount of bytes read from fd.
Proposed Change My solution that fixes this looks like the following:
def ql_syscall_readv(ql: Qiling, fd: int, vec: int, vlen: int): regreturn = 0 size_t_len = ql.arch.pointersize iov = ql.mem.read(vec, vlen * size_t_len * 2) ql.log.debug('readv() CONTENT:') for i in range(vlen): addr = ql.unpack(iov[i * size_t_len * 2 : i * size_t_len * 2 + size_t_len]) l = ql.unpack(iov[i * size_t_len * 2 + size_t_len : i * size_t_len * 2 + size_t_len * 2]) if hasattr(ql.os.fd[fd], 'read'): data = ql.os.fd[fd].read(l) ql.log.debug(f'{data!r}') ql.mem.write(addr, data) regreturn += len(data) return regreturn
The text was updated successfully, but these errors were encountered:
elicn
No branches or pull requests
*Describe the bug
readv()
according to the manpages should return the number of bytes read but it seems to return the size of the iovec everytime???Sample Code
Expected behavior
readv()
should return the amount of bytes read from fd.Proposed Change
My solution that fixes this looks like the following:
The text was updated successfully, but these errors were encountered: