tar-1.34-fix-cve-2022-48303.patch 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. Gentoo Bug: https://bugs.gentoo.org/898176
  2. Upstream Commit Link: https://git.savannah.gnu.org/cgit/tar.git/commit/?id=3da78400eafcccb97e2f2fd4b227ea40d794ede8
  3. From 3da78400eafcccb97e2f2fd4b227ea40d794ede8 Mon Sep 17 00:00:00 2001
  4. From: Sergey Poznyakoff <gray@gnu.org>
  5. Date: Sat, 11 Feb 2023 11:57:39 +0200
  6. Subject: [PATCH] Fix boundary checking in base-256 decoder
  7. * src/list.c (from_header): Base-256 encoding is at least 2 bytes
  8. long.
  9. ---
  10. src/list.c | 5 +++--
  11. 1 file changed, 3 insertions(+), 2 deletions(-)
  12. diff --git a/src/list.c b/src/list.c
  13. index 9fafc425..86bcfdd1 100644
  14. --- a/src/list.c
  15. +++ b/src/list.c
  16. @@ -881,8 +881,9 @@ from_header (char const *where0, size_t digs, char const *type,
  17. where++;
  18. }
  19. }
  20. - else if (*where == '\200' /* positive base-256 */
  21. - || *where == '\377' /* negative base-256 */)
  22. + else if (where <= lim - 2
  23. + && (*where == '\200' /* positive base-256 */
  24. + || *where == '\377' /* negative base-256 */))
  25. {
  26. /* Parse base-256 output. A nonnegative number N is
  27. represented as (256**DIGS)/2 + N; a negative number -N is
  28. --
  29. 2.39.2.637.g21b0678d19-goog