fix embedded null in cmdline string

pull/1882/head
smiley 2 years ago committed by Disconnect3d
parent 41c5dc7a49
commit 7abeef6560

@ -87,7 +87,8 @@ class Process:
@pwndbg.lib.cache.cache_until("stop") @pwndbg.lib.cache.cache_until("stop")
def cmdline(self): def cmdline(self):
raw = pwndbg.gdblib.file.get(f"/proc/{self.pid}/cmdline") raw = pwndbg.gdblib.file.get(f"/proc/{self.pid}/cmdline")
return f"'{raw.decode()}'" cmdline = raw.decode().rstrip("\x00").strip()
return f"'{cmdline}'"
@property @property
@pwndbg.lib.cache.cache_until("stop") @pwndbg.lib.cache.cache_until("stop")
@ -223,7 +224,7 @@ def procinfo() -> None:
if not proc.status: if not proc.status:
return return
# print("%-10s %s" % ("cmdline", proc.something)) print("%-10s %s" % ("cmdline", proc.cmdline))
print("%-10s %s" % ("cwd", proc.cwd)) print("%-10s %s" % ("cwd", proc.cwd))

@ -38,7 +38,7 @@ def test_command_procinfo(start_binary):
res_list = result.split("\n") res_list = result.split("\n")
assert bin_path in res_list[0] assert bin_path in res_list[0]
assert pid in res_list[2] assert pid in res_list[3]
assert "127.0.0.1:31337" in result assert "127.0.0.1:31337" in result
# Close netcat # Close netcat

Loading…
Cancel
Save