66b169c
From 8f26482402179dc64b9488be05ef9686922446ec Mon Sep 17 00:00:00 2001
66b169c
From: Jakub Filak <jfilak@redhat.com>
66b169c
Date: Fri, 24 Jul 2015 13:50:00 +0200
66b169c
Subject: [PATCH] vmcore: read vmcore by chunks
66b169c
66b169c
Reading vmcore by lines was not a good idea and the switch to Python 3
66b169c
makes it impossible because of the binary format of that file (the file
66b169c
does not contain only valid Unicode strings and that raises
66b169c
UnicodeDecodeError from the for statement).
66b169c
66b169c
Signed-off-by: Jakub Filak <jfilak@redhat.com>
66b169c
---
66b169c
 src/hooks/abrt_harvest_vmcore.py.in | 9 ++++++---
66b169c
 1 file changed, 6 insertions(+), 3 deletions(-)
66b169c
66b169c
diff --git a/src/hooks/abrt_harvest_vmcore.py.in b/src/hooks/abrt_harvest_vmcore.py.in
66b169c
index c5e7d53..61a6e57 100644
66b169c
--- a/src/hooks/abrt_harvest_vmcore.py.in
66b169c
+++ b/src/hooks/abrt_harvest_vmcore.py.in
66b169c
@@ -214,9 +214,12 @@ def harvest_vmcore():
66b169c
         hashobj = hashlib.sha1()
66b169c
         # Iterate over the file a line at a time in order to not load the whole
66b169c
         # vmcore file
66b169c
-        with open(os.path.join(f_full, 'vmcore'), 'r') as corefile:
66b169c
-            for line in corefile:
66b169c
-                hashobj.update(line)
66b169c
+        with open(os.path.join(f_full, 'vmcore'), 'rb') as corefile:
66b169c
+            while True:
66b169c
+                chunk = corefile.read(8192)
66b169c
+                if not chunk:
66b169c
+                    break
66b169c
+                hashobj.update(chunk)
66b169c
 
66b169c
         dd = create_abrtd_info(destdirnew, hashobj.hexdigest())
66b169c
         if dd is None:
66b169c
-- 
66b169c
2.4.6
66b169c