iotop/0021-data.py-get_cmdline-use-errors-replace-for-unicode-e.patch
lvyy b15981b914 Fix the iotop crash caused by non-UTF-8 characters
(cherry picked from commit 3a8a39dc317e68dc92955322e427ae560c554558)
2024-12-17 10:51:55 +08:00

33 lines
1.1 KiB
Diff

From 4b2e1aa2464cfc4a29c9565c9e143b52ef8e4848 Mon Sep 17 00:00:00 2001
From: Dominique Martinet <dominique.martinet@atmark-techno.com>
Date: Mon, 3 Apr 2023 18:09:29 +0900
Subject: [PATCH] data.py get_cmdline: use errors=replace for unicode errors
/proc/pid/cmdline is user-controlled and not necessarily valid unicode,
just replace bogus characters like already done for /proc/pid/status.
See-also: commit 443737ec620a699286b9b2e44dbcaac53f553812
Conflict: NA
Reference: https://repo.or.cz/iotop.git/commit/4b2e1aa2464cfc4a29c9565c9e143b52ef8e4848
---
iotop/data.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/iotop/data.py b/iotop/data.py
index f5496d0..8c1acae 100644
--- a/iotop/data.py
+++ b/iotop/data.py
@@ -307,7 +307,7 @@ class ProcessInfo(DumpableObject):
def get_cmdline(self):
# A process may exec, so we must always reread its cmdline
try:
- proc_cmdline = open('/proc/%d/cmdline' % self.pid)
+ proc_cmdline = open('/proc/%d/cmdline' % self.pid, errors='replace')
cmdline = proc_cmdline.read(4096)
except IOError:
return '{no such process}'
--
2.33.0