diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2020-04-11 20:53:00 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-11 20:53:00 (GMT) |
commit | 2714c907df7cfe97911df6ce90364001270d9a43 (patch) | |
tree | 9926f4cc3f43cb0df25385d12a852bc9a8ac783b /Tools | |
parent | ceba0648d70524ec4ebb7a46d5d1162d4938c7ba (diff) | |
download | cpython-2714c907df7cfe97911df6ce90364001270d9a43.zip cpython-2714c907df7cfe97911df6ce90364001270d9a43.tar.gz cpython-2714c907df7cfe97911df6ce90364001270d9a43.tar.bz2 |
closes bpo-39953: Update OpenSSL error codes table. (GH-19082)
I updated the error codes using the OpenSSL 1.1.1f source tree.
(cherry picked from commit 3e0dd3730b5eff7e9ae6fb921aa77cd26efc9e3a)
Co-authored-by: Benjamin Peterson <benjamin@python.org>
Diffstat (limited to 'Tools')
-rwxr-xr-x | Tools/ssl/make_ssl_data.py | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/Tools/ssl/make_ssl_data.py b/Tools/ssl/make_ssl_data.py index 3fb4985..2297c85 100755 --- a/Tools/ssl/make_ssl_data.py +++ b/Tools/ssl/make_ssl_data.py @@ -11,6 +11,7 @@ It takes two arguments: """ import datetime +import glob import os import re import sys @@ -18,7 +19,7 @@ import _ssl def parse_error_codes(h_file, prefix, libcode): - pat = re.compile(r"#define\W+(%s([\w]+))\W+(\d+)\b" % re.escape(prefix)) + pat = re.compile(r"#\s*define\W+(%s([\w]+))\W+(\d+)\b" % re.escape(prefix)) codes = [] with open(h_file, "r", encoding="latin1") as f: for line in f: @@ -28,6 +29,7 @@ def parse_error_codes(h_file, prefix, libcode): num = int(num) # e.g. ("SSL_R_BAD_DATA", ("ERR_LIB_SSL", "BAD_DATA", 390)) codes.append((code, (libcode, name, num))) + assert codes, f"no codes found in {h_file}" return codes if __name__ == "__main__": @@ -35,18 +37,23 @@ if __name__ == "__main__": outfile = sys.argv[2] use_stdout = outfile == '-' f = sys.stdout if use_stdout else open(outfile, "w") - error_libraries = { - # mnemonic -> (library code, error prefix, header file) - 'PEM': ('ERR_LIB_PEM', 'PEM_R_', 'crypto/pem/pem.h'), - 'SSL': ('ERR_LIB_SSL', 'SSL_R_', 'ssl/ssl.h'), - 'X509': ('ERR_LIB_X509', 'X509_R_', 'crypto/x509/x509.h'), - } + # mnemonic -> (library code, error prefix, header file) + error_libraries = {} + for error_header in glob.glob(os.path.join(openssl_inc, 'include/openssl/*err.h')): + base = os.path.basename(error_header) + if base in ('buffererr.h', 'objectserr.h', 'storeerr.h'): + # Deprecated in 3.0. + continue + mnemonic = base[:-5].upper() + if mnemonic == "": + # Skip err.h. + continue + error_libraries[mnemonic] = (f'ERR_LIB_{mnemonic}', f'{mnemonic}_R_', error_header) # Read codes from libraries new_codes = [] for libcode, prefix, h_file in sorted(error_libraries.values()): - new_codes += parse_error_codes(os.path.join(openssl_inc, h_file), - prefix, libcode) + new_codes += parse_error_codes(h_file, prefix, libcode) new_code_nums = set((libcode, num) for (code, (libcode, name, num)) in new_codes) |