closes bpo-39953: Update OpenSSL error codes table. (GH-19082)
I updated the error codes using the OpenSSL 1.1.1f source tree.
This commit is contained in:
parent
4b222c9491
commit
3e0dd3730b
|
@ -0,0 +1 @@
|
||||||
|
Update internal table of OpenSSL error codes in the ``ssl`` module.
|
5087
Modules/_ssl_data.h
5087
Modules/_ssl_data.h
File diff suppressed because it is too large
Load Diff
|
@ -11,6 +11,7 @@ It takes two arguments:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
import glob
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
@ -18,7 +19,7 @@ import _ssl
|
||||||
|
|
||||||
|
|
||||||
def parse_error_codes(h_file, prefix, libcode):
|
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 = []
|
codes = []
|
||||||
with open(h_file, "r", encoding="latin1") as f:
|
with open(h_file, "r", encoding="latin1") as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
|
@ -28,6 +29,7 @@ def parse_error_codes(h_file, prefix, libcode):
|
||||||
num = int(num)
|
num = int(num)
|
||||||
# e.g. ("SSL_R_BAD_DATA", ("ERR_LIB_SSL", "BAD_DATA", 390))
|
# e.g. ("SSL_R_BAD_DATA", ("ERR_LIB_SSL", "BAD_DATA", 390))
|
||||||
codes.append((code, (libcode, name, num)))
|
codes.append((code, (libcode, name, num)))
|
||||||
|
assert codes, f"no codes found in {h_file}"
|
||||||
return codes
|
return codes
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -35,18 +37,23 @@ if __name__ == "__main__":
|
||||||
outfile = sys.argv[2]
|
outfile = sys.argv[2]
|
||||||
use_stdout = outfile == '-'
|
use_stdout = outfile == '-'
|
||||||
f = sys.stdout if use_stdout else open(outfile, "w")
|
f = sys.stdout if use_stdout else open(outfile, "w")
|
||||||
error_libraries = {
|
# mnemonic -> (library code, error prefix, header file)
|
||||||
# mnemonic -> (library code, error prefix, header file)
|
error_libraries = {}
|
||||||
'PEM': ('ERR_LIB_PEM', 'PEM_R_', 'crypto/pem/pem.h'),
|
for error_header in glob.glob(os.path.join(openssl_inc, 'include/openssl/*err.h')):
|
||||||
'SSL': ('ERR_LIB_SSL', 'SSL_R_', 'ssl/ssl.h'),
|
base = os.path.basename(error_header)
|
||||||
'X509': ('ERR_LIB_X509', 'X509_R_', 'crypto/x509/x509.h'),
|
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
|
# Read codes from libraries
|
||||||
new_codes = []
|
new_codes = []
|
||||||
for libcode, prefix, h_file in sorted(error_libraries.values()):
|
for libcode, prefix, h_file in sorted(error_libraries.values()):
|
||||||
new_codes += parse_error_codes(os.path.join(openssl_inc, h_file),
|
new_codes += parse_error_codes(h_file, prefix, libcode)
|
||||||
prefix, libcode)
|
|
||||||
new_code_nums = set((libcode, num)
|
new_code_nums = set((libcode, num)
|
||||||
for (code, (libcode, name, num)) in new_codes)
|
for (code, (libcode, name, num)) in new_codes)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue