JonathanSalwan/ROPgadget

ROPgadget -c (update) fails

MisterAero opened this issue · 2 comments

ROPgadget -c
Traceback (most recent call last):
File "/home/aero/.local/bin/ROPgadget", line 12, in
ropgadget.main()
File "/home/aero/.local/lib/python3.8/site-packages/ropgadget/init.py", line 26, in main
args = Args()
File "/home/aero/.local/lib/python3.8/site-packages/ropgadget/args.py", line 26, in init
self.__parse(arguments, custom_arguments_provided)
File "/home/aero/.local/lib/python3.8/site-packages/ropgadget/args.py", line 132, in __parse
UpdateAlert().checkUpdate()
File "/home/aero/.local/lib/python3.8/site-packages/ropgadget/updateAlert.py", line 30, in checkUpdate
majorVersion = re.search("MAJOR_VERSION.+=.+(?P[\d])", d).group("value")
File "/usr/lib/python3.8/re.py", line 201, in search
return _compile(pattern, flags).search(string)
TypeError: cannot use a string pattern on a bytes-like object

Could it be because of not using the latest version of pip3?

I guess something like this should resolve this issue

diff --git a/ropgadget/updateAlert.py b/ropgadget/updateAlert.py
index 3a6ef85..85e5a2e 100644
--- a/ropgadget/updateAlert.py
+++ b/ropgadget/updateAlert.py
@@ -26,7 +26,7 @@ class UpdateAlert(object):
         except:
             print("Can't connect to raw.githubusercontent.com")
             return
-        d = conn.getresponse().read()
+        d = conn.getresponse().read().decode()
         majorVersion = re.search("MAJOR_VERSION.+=.+(?P<value>[\d])", d).group("value")
         minorVersion = re.search("MINOR_VERSION.+=.+(?P<value>[\d])", d).group("value")
         webVersion = int("%s%s" % (majorVersion, minorVersion))

@nurmukhametov, yeah, this fixes an issue. Would you like to propose a PR?