0012-rf64-fix-int-overflow-in-rf64_read_header.patch 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. From 49704025956f03751d3436a0bb42287cd7f434b6 Mon Sep 17 00:00:00 2001
  2. From: Alex Stewart <alex.stewart@ni.com>
  3. Date: Tue, 17 Oct 2023 12:01:00 -0400
  4. Subject: [PATCH] rf64: fix int overflow in rf64_read_header()
  5. When checking for mismatches between the filelength and riff_size, it is
  6. possible to overflow the temporary riff_size value used in the
  7. comparison by adding a static offset; which is probably fine, but it is
  8. offensive to overflow fuzzers.
  9. Since filelength is always a positive value, simply move the offset to
  10. the other side of the comparison operator as a negative value, avoid the
  11. possibility of an overflow.
  12. CVE: CVE-2022-33065
  13. Fixes: https://github.com/libsndfile/libsndfile/issues/833
  14. Signed-off-by: Alex Stewart <alex.stewart@ni.com>
  15. Upstream: https://github.com/libsndfile/libsndfile/commit/49704025956f03751d3436a0bb42287cd7f434b6
  16. Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
  17. ---
  18. src/rf64.c | 2 +-
  19. 1 file changed, 1 insertion(+), 1 deletion(-)
  20. diff --git a/src/rf64.c b/src/rf64.c
  21. index 123db445..c60399fb 100644
  22. --- a/src/rf64.c
  23. +++ b/src/rf64.c
  24. @@ -242,7 +242,7 @@ rf64_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock)
  25. } ;
  26. } ;
  27. - if (psf->filelength != riff_size + 8)
  28. + if (psf->filelength - 8 != riff_size)
  29. psf_log_printf (psf, " Riff size : %D (should be %D)\n", riff_size, psf->filelength - 8) ;
  30. else
  31. psf_log_printf (psf, " Riff size : %D\n", riff_size) ;
  32. --
  33. 2.39.5