diff options
author | Benjamin Peterson <benjamin@python.org> | 2020-04-11 20:36:12 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-11 20:36:12 (GMT) |
commit | 3e0dd3730b5eff7e9ae6fb921aa77cd26efc9e3a (patch) | |
tree | b36ab9c7bbe6eb306a7ccc24412fd4ed143a2284 /Tools/ssl | |
parent | 4b222c9491d1700e9bdd98e6889b8d0ea1c7321e (diff) | |
download | cpython-3e0dd3730b5eff7e9ae6fb921aa77cd26efc9e3a.zip cpython-3e0dd3730b5eff7e9ae6fb921aa77cd26efc9e3a.tar.gz cpython-3e0dd3730b5eff7e9ae6fb921aa77cd26efc9e3a.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.
Diffstat (limited to 'Tools/ssl')
-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 fdabd5d..1c7a5a9 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) |