0005-aiff-fix-int-overflow-when-counting-header-elements.patch 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. From 187451dbd3c044f9a76b6c1d950d458de0103180 Mon Sep 17 00:00:00 2001
  2. From: Alex Stewart <alex.stewart@ni.com>
  3. Date: Wed, 11 Oct 2023 17:26:51 -0400
  4. Subject: [PATCH] aiff: fix int overflow when counting header elements
  5. aiff_read_basc_chunk() tries to count the AIFF header size by keeping
  6. track of the bytes returned by psf_binheader_readf(). Though improbable,
  7. it is technically possible for these added bytes to exceed the int-sized
  8. `count` accumulator.
  9. Use a 64-bit sf_count_t type for `count`, to ensure that it always has
  10. enough numeric space.
  11. CVE: CVE-2022-33065
  12. Fixes: https://github.com/libsndfile/libsndfile/issues/833
  13. Signed-off-by: Alex Stewart <alex.stewart@ni.com>
  14. Upstream: https://github.com/libsndfile/libsndfile/commit/187451dbd3c044f9a76b6c1d950d458de0103180
  15. Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
  16. ---
  17. src/aiff.c | 2 +-
  18. 1 file changed, 1 insertion(+), 1 deletion(-)
  19. diff --git a/src/aiff.c b/src/aiff.c
  20. index ac3655e9..6d8f1bc8 100644
  21. --- a/src/aiff.c
  22. +++ b/src/aiff.c
  23. @@ -1702,7 +1702,7 @@ static int
  24. aiff_read_basc_chunk (SF_PRIVATE * psf, int datasize)
  25. { const char * type_str ;
  26. basc_CHUNK bc ;
  27. - int count ;
  28. + sf_count_t count ;
  29. count = psf_binheader_readf (psf, "E442", &bc.version, &bc.numBeats, &bc.rootNote) ;
  30. count += psf_binheader_readf (psf, "E222", &bc.scaleType, &bc.sigNumerator, &bc.sigDenominator) ;
  31. --
  32. 2.39.5