OSDN Git Service

Fix btsnooz.py multi-line base64 decoding
authorAndre Eisenbach <eisenbach@google.com>
Sat, 2 Apr 2016 00:47:54 +0000 (17:47 -0700)
committerAndre Eisenbach <eisenbach@google.com>
Mon, 4 Apr 2016 18:44:09 +0000 (18:44 +0000)
Change-Id: Ie915c52d8a7eada10f68999c40a2b50b35f640e2

tools/scripts/btsnooz.py

index 4d85081..6e0e112 100755 (executable)
@@ -146,11 +146,21 @@ def main():
     exit(1)
 
   iterator = fileinput.input()
+  found = False
+  base64_string = ""
   for line in iterator:
+    if found:
+      if line.find('--- END:BTSNOOP_LOG_SUMMARY') != -1:
+        decode_snooz(base64.standard_b64decode(base64_string))
+        sys.exit(0)
+      base64_string += line.strip()
+
     if line.find('--- BEGIN:BTSNOOP_LOG_SUMMARY') != -1:
-      decode_snooz(base64.standard_b64decode(iterator.next()))
-      sys.exit(0)
-  sys.stderr.write('No btsnooz section found in bugreport.\n');
+      found = True
+
+  if not found:
+    sys.stderr.write('No btsnooz section found in bugreport.\n')
+    sys.exit(1)
 
 
 if __name__ == '__main__':