Regnual update tool: do not allow other than binary formats (upgrade_by_passwd)
authorSzczepan Zalega <szczepan@nitrokey.com>
Mon, 2 Jan 2017 17:44:47 +0000 (18:44 +0100)
committerNIIBE Yutaka <gniibe@fsij.org>
Wed, 1 Feb 2017 06:40:56 +0000 (15:40 +0900)
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
ChangeLog
tool/upgrade_by_passwd.py

index e777c33..a925eac 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2017-01-02  Szczepan Zalega <szczepan@nitrokey.com>
+
+       * tool/upgrade_by_passwd.py: Add file extention check.
+
 2017-02-01  NIIBE Yutaka  <gniibe@fsij.org>
 
        * tool/upgrade_by_passwd.py (main): More verbose messages
index 18d9b46..f76f9e2 100755 (executable)
@@ -124,6 +124,9 @@ if __name__ == '__main__':
         passwd = getpass("Admin password: ")
     filename_regnual = sys.argv[1]
     filename_upgrade = sys.argv[2]
+    if not filename_regnual.endswith('bin') or not filename_upgrade.endswith('bin'):
+        print("Both input files must be in binary format (*.bin)!")
+        exit(1)
     f = open(filename_regnual,"rb")
     data_regnual = f.read()
     f.close()