fix: adjust to `rr`'s vFile reply (#2850)

* fix: adjust to `rr`'s vFile reply

`rr replay` use `"F-01,2"` to indicate a vFile error while pwndbg
detects `"F-1,"`. Patch the code to process some cases like `rr`.

* edit: add a ` ` to satisfy lint.

* aglib.file: apply to potential `"errno;attachment"`

* edit: satisfy reviewdog

* aglib.file: skip `attachment` when parsing vFile

> F result [,errno] [;attachment]

`attachment` is what we don't need, strip it before parsing result and
errno

* aglib.file: remove duplicated split
pull/2853/head
RocketDev 8 months ago committed by GitHub
parent 42e5bd60b0
commit 574e3125f0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -170,9 +170,14 @@ def is_vfile_qemu_user_bug() -> bool:
def _vfile_check_response(response: bytes):
if len(response) == 0:
raise NotImplementedError("Not supported")
if response.startswith(b"F-1,"):
errno = int(response[4:].decode(), 10 if is_vfile_qemu_user_bug() else 16)
raise OSError(errno, "Error")
# F result [,errno] [;attachment]; strip attachment first, skip if no errno
result_errno = response.split(b";", 1)[0]
if result_errno.startswith(b"F") and b"," in result_errno:
result, errno = result_errno[1:].split(b",", 1) # Skip "F"
if int(result) != -1:
raise NotImplementedError(f"Unknown response status {result!r}")
err = int(errno, 10 if is_vfile_qemu_user_bug() else 16)
raise OSError(err, "Error")
def vfile_readlink(pathname: str | bytes) -> bytes:

Loading…
Cancel
Save