0026-lib-crypt-uClibc-ng-doesn-t-set-errno-when-encryptio.patch 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. From d6706e827f703c63ab519d104c53833fa5cebe03 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. [Daniel: updated for 3.10.7]
  16. Signed-off-by: Daniel Lang <d.lang@abatec.at>
  17. ---
  18. Lib/crypt.py | 4 +++-
  19. 1 file changed, 3 insertions(+), 1 deletion(-)
  20. diff --git a/Lib/crypt.py b/Lib/crypt.py
  21. index de4a14a3884..ba482487a7a 100644
  22. --- a/Lib/crypt.py
  23. +++ b/Lib/crypt.py
  24. @@ -98,7 +98,9 @@ def _add_method(name, *args, rounds=None):
  25. result = crypt('', salt)
  26. except OSError as e:
  27. # Not all libc libraries support all encryption methods.
  28. - if e.errno in {errno.EINVAL, errno.EPERM, errno.ENOSYS}:
  29. + # Not all libc libraries set errno when encryption method is not
  30. + # available.
  31. + if e.errno in {errno.EINVAL, errno.EPERM, errno.ENOSYS} or e.errno == 0:
  32. return False
  33. raise
  34. if result and len(result) == method.total_size:
  35. --
  36. 2.44.0