0034-lib-crypt-uClibc-ng-doesn-t-set-errno-when-encryptio.patch 1.5 KB

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