1*4882a593SmuzhiyunFrom 3c83eedcc2df3ecf6c4a17953ca24dff60c1378e Mon Sep 17 00:00:00 2001
2*4882a593SmuzhiyunFrom: Romain Naour <romain.naour@gmail.com>
3*4882a593SmuzhiyunDate: Thu, 12 Nov 2020 00:16:18 +0100
4*4882a593SmuzhiyunSubject: [PATCH] lib/crypt: uClibc-ng doesn't set errno when encryption method
5*4882a593Smuzhiyun is not available
6*4882a593Smuzhiyun
7*4882a593SmuzhiyunSince commit [1] in cpython, an exception is raised when an encryption method
8*4882a593Smuzhiyunis not available. This eception is handled only if errno is set to EINVAL by
9*4882a593Smuzhiyuncrypt() but uClibc-ng doesn't set errno in crypt() [2].
10*4882a593Smuzhiyun
11*4882a593SmuzhiyunFixes:
12*4882a593Smuzhiyunhttps://gitlab.com/buildroot.org/buildroot/-/jobs/830981961
13*4882a593Smuzhiyunhttps://gitlab.com/buildroot.org/buildroot/-/jobs/830981979
14*4882a593Smuzhiyun
15*4882a593Smuzhiyun[1] https://github.com/python/cpython/commit/0d3fe8ae4961bf551e7d5e42559e2ede1a08fd7c
16*4882a593Smuzhiyun[2] https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/tree/libcrypt/crypt.c?h=v1.0.36#n29
17*4882a593Smuzhiyun
18*4882a593SmuzhiyunSigned-off-by: Romain Naour <romain.naour@gmail.com>
19*4882a593Smuzhiyun---
20*4882a593Smuzhiyun Lib/crypt.py | 4 +++-
21*4882a593Smuzhiyun 1 file changed, 3 insertions(+), 1 deletion(-)
22*4882a593Smuzhiyun
23*4882a593Smuzhiyundiff --git a/Lib/crypt.py b/Lib/crypt.py
24*4882a593Smuzhiyunindex 33dbc46bb3..4692a5270c 100644
25*4882a593Smuzhiyun--- a/Lib/crypt.py
26*4882a593Smuzhiyun+++ b/Lib/crypt.py
27*4882a593Smuzhiyun@@ -94,7 +94,9 @@ def _add_method(name, *args, rounds=None):
28*4882a593Smuzhiyun         result = crypt('', salt)
29*4882a593Smuzhiyun     except OSError as e:
30*4882a593Smuzhiyun         # Not all libc libraries support all encryption methods.
31*4882a593Smuzhiyun-        if e.errno == errno.EINVAL:
32*4882a593Smuzhiyun+        # Not all libc libraries set errno when encryption method is not
33*4882a593Smuzhiyun+        # available.
34*4882a593Smuzhiyun+        if e.errno == errno.EINVAL or e.errno == 0:
35*4882a593Smuzhiyun             return False
36*4882a593Smuzhiyun         raise
37*4882a593Smuzhiyun     if result and len(result) == method.total_size:
38*4882a593Smuzhiyun--
39*4882a593Smuzhiyun2.25.4
40*4882a593Smuzhiyun
41