From 574e3125f000a085266ce3bf9182472c67cd7479 Mon Sep 17 00:00:00 2001 From: RocketDev <13736845354@163.com> Date: Thu, 10 Apr 2025 00:03:08 +0800 Subject: [PATCH] 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 --- pwndbg/aglib/file.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pwndbg/aglib/file.py b/pwndbg/aglib/file.py index ef03fb4e8..b9f62ddac 100644 --- a/pwndbg/aglib/file.py +++ b/pwndbg/aglib/file.py @@ -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: