From f124f1845afc9b4383e660accacf12cf661318c3 Mon Sep 17 00:00:00 2001 From: Eric Hennenfent Date: Thu, 17 Jan 2019 11:21:44 -0600 Subject: [PATCH] Make sys_lseek return offset location Per the [man page](http://man7.org/linux/man-pages/man2/lseek.2.html#RETURN_VALUE), `lseek` should return the offset location as measured in bytes from the beginning of the file. --- manticore/platforms/linux.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/manticore/platforms/linux.py b/manticore/platforms/linux.py index f62b8d4e8..564c64f1f 100644 --- a/manticore/platforms/linux.py +++ b/manticore/platforms/linux.py @@ -1248,19 +1248,17 @@ def sys_lseek(self, fd, offset, whence): SEEK_CUR: The file offset is set to its current location plus offset bytes. SEEK_END: The file offset is set to the size of the file plus offset bytes. - :return: 0 (Success), or EBADF (fd is not a valid file descriptor or is not open) + :return: offset from file beginning, or EBADF (fd is not a valid file descriptor or is not open) ''' signed_offset = self._to_signed_dword(offset) try: - self._get_fd(fd).seek(signed_offset, whence) + return self._get_fd(fd).seek(signed_offset, whence) except FdError as e: logger.info(("LSEEK: Not valid file descriptor on lseek." "Fd not seekable. Returning EBADF")) return -e.err - return 0 - def sys_read(self, fd, buf, count): data: bytes = bytes() if count != 0: