diff options
-rw-r--r-- | .topdeps | 1 | ||||
-rw-r--r-- | .topmsg | 7 | ||||
-rw-r--r-- | src/sugar/profile.py | 6 |
3 files changed, 13 insertions, 1 deletions
diff --git a/.topdeps b/.topdeps new file mode 100644 index 0000000..9c9ac90 --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +upstream/master @@ -0,0 +1,7 @@ +From: Sascha Silbe <sascha-pgp@silbe.org> +Subject: [PATCH] check syntax of private key (#1568) + +Check that header and footer of the private key are present in order to detect +corrupted key files. + +Signed-off-by: Sascha Silbe <sascha-pgp@silbe.org> diff --git a/src/sugar/profile.py b/src/sugar/profile.py index 3ea1e67..3f93bba 100644 --- a/src/sugar/profile.py +++ b/src/sugar/profile.py @@ -105,14 +105,18 @@ class Profile(object): return None key = "" + begin_found = False + end_found = False for l in lines: l = l.strip() if l.startswith("-----BEGIN DSA PRIVATE KEY-----"): + begin_found = True continue if l.startswith("-----END DSA PRIVATE KEY-----"): + end_found = True continue key += l - if not len(key): + if not (len(key) and begin_found and end_found): logging.error("Error parsing public key.") return None |