0002-Fix-boundary-checking-in-base-256-decoder.patch 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. From 3da78400eafcccb97e2f2fd4b227ea40d794ede8 Mon Sep 17 00:00:00 2001
  2. From: Sergey Poznyakoff <gray@gnu.org>
  3. Date: Sat, 11 Feb 2023 11:57:39 +0200
  4. Subject: [PATCH] Fix boundary checking in base-256 decoder
  5. * src/list.c (from_header): Base-256 encoding is at least 2 bytes
  6. long.
  7. Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
  8. Upstream: https://git.savannah.gnu.org/cgit/tar.git/commit/?id=3da78400eafcccb97e2f2fd4b227ea40d794ede8
  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