0001-Do-something-sensible-for-empty-strings-to-make-fuzz.patch 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. From fa7438a0ff4033e4741c807394a9af6207940d71 Mon Sep 17 00:00:00 2001
  2. From: Joerg Sonnenberger <joerg@bec.de>
  3. Date: Tue, 5 Sep 2017 18:12:19 +0200
  4. Subject: [PATCH] Do something sensible for empty strings to make fuzzers
  5. happy.
  6. Signed-off-by: Baruch Siach <baruch@tkos.co.il>
  7. ---
  8. Upstream status: commit fa7438a0ff
  9. libarchive/archive_read_support_format_xar.c | 8 +++++++-
  10. 1 file changed, 7 insertions(+), 1 deletion(-)
  11. diff --git a/libarchive/archive_read_support_format_xar.c b/libarchive/archive_read_support_format_xar.c
  12. index 7a22beb9d8e4..93eeacc5e6eb 100644
  13. --- a/libarchive/archive_read_support_format_xar.c
  14. +++ b/libarchive/archive_read_support_format_xar.c
  15. @@ -1040,6 +1040,9 @@ atol10(const char *p, size_t char_cnt)
  16. uint64_t l;
  17. int digit;
  18. + if (char_cnt == 0)
  19. + return (0);
  20. +
  21. l = 0;
  22. digit = *p - '0';
  23. while (digit >= 0 && digit < 10 && char_cnt-- > 0) {
  24. @@ -1054,7 +1057,10 @@ atol8(const char *p, size_t char_cnt)
  25. {
  26. int64_t l;
  27. int digit;
  28. -
  29. +
  30. + if (char_cnt == 0)
  31. + return (0);
  32. +
  33. l = 0;
  34. while (char_cnt-- > 0) {
  35. if (*p >= '0' && *p <= '7')
  36. --
  37. 2.14.1