Attachments you submit will be routed for moderation. If you have an account, please log in first.

Ticket #1568: sugar-toolkit-1568.patch

File sugar-toolkit-1568.patch, 1.2 KB (added by sascha_silbe, 3 years ago)

check private key syntax

  • src/sugar/profile.py

    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>
    
    ---
     src/sugar/profile.py |    6 +++++-
     1 files changed, 5 insertions(+), 1 deletions(-)
    
    diff --git a/src/sugar/profile.py b/src/sugar/profile.py
    index 3ea1e67..3f93bba 100644
    a b  
    105105            return None 
    106106 
    107107        key = "" 
     108        begin_found = False 
     109        end_found = False 
    108110        for l in lines: 
    109111            l = l.strip() 
    110112            if l.startswith("-----BEGIN DSA PRIVATE KEY-----"): 
     113                begin_found = True 
    111114                continue 
    112115            if l.startswith("-----END DSA PRIVATE KEY-----"): 
     116                end_found = True 
    113117                continue 
    114118            key += l 
    115         if not len(key): 
     119        if not (len(key) and begin_found and end_found): 
    116120            logging.error("Error parsing public key.") 
    117121            return None 
    118122