From 52938a80766fc3c5eeddc85d16e8e8b6f0c33f9f Mon Sep 17 00:00:00 2001 From: Robin Richtsfeld Date: Sat, 23 Feb 2019 03:24:39 +0100 Subject: [PATCH 1/2] Fix encoding error and error suppression The try-except swallowed the following error: `ord() expected string of length 1, but int found` Poor error handling resulted in a syntax error and subsequent compilation failure in `Updater.cpp` --- tools/signing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/signing.py b/tools/signing.py index a323cbc0cc..e3aff25b3c 100755 --- a/tools/signing.py +++ b/tools/signing.py @@ -22,7 +22,7 @@ def main(): if args.mode == "header": val = "" try: - with open(args.publickey, "rb") as f: + with open(args.publickey, "r") as f: pub = f.read() val += "#include \n" val += "#define ARDUINO_SIGNING 1\n" @@ -32,7 +32,7 @@ def main(): val = val[:-3] val +="\n};\n" sys.stderr.write("Enabling binary signing\n") - except: + except IOError: # Silence the default case to avoid people thinking something is wrong. # Only people who care about signing will know what it means, anyway, # and they can check for the positive acknowledgement above. From 109a8e60efea812b84ccff81eb5239bdc00b0405 Mon Sep 17 00:00:00 2001 From: Robin Richtsfeld Date: Sun, 24 Feb 2019 01:26:27 +0100 Subject: [PATCH 2/2] Use bytearray --- tools/signing.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/signing.py b/tools/signing.py index e3aff25b3c..0f266fd8f4 100755 --- a/tools/signing.py +++ b/tools/signing.py @@ -22,13 +22,13 @@ def main(): if args.mode == "header": val = "" try: - with open(args.publickey, "r") as f: + with open(args.publickey, "rb") as f: pub = f.read() val += "#include \n" val += "#define ARDUINO_SIGNING 1\n" val += "static const char signing_pubkey[] PROGMEM = {\n" - for i in pub: - val += "0x%02x, \n" % ord(i) + for i in bytearray(pub): + val += "0x%02x, \n" % i val = val[:-3] val +="\n};\n" sys.stderr.write("Enabling binary signing\n")