0003-avr-fix-int-overflow-in-avr_read_header.patch 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. From 2f8eece78cc8b4dce6c95b3045867f0936714db8 Mon Sep 17 00:00:00 2001
  2. From: Alex Stewart <alex.stewart@ni.com>
  3. Date: Wed, 11 Oct 2023 16:46:29 -0400
  4. Subject: [PATCH] avr: fix int overflow in avr_read_header()
  5. Pre-cast hdr.frames to sf_count_t, to provide the calculation with
  6. enough numeric space to avoid an int-overflow.
  7. CVE: CVE-2022-33065
  8. Fixes: https://github.com/libsndfile/libsndfile/issues/833
  9. Signed-off-by: Alex Stewart <alex.stewart@ni.com>
  10. Upstream: https://github.com/libsndfile/libsndfile/commit/2f8eece78cc8b4dce6c95b3045867f0936714db8
  11. Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
  12. ---
  13. src/avr.c | 2 +-
  14. 1 file changed, 1 insertion(+), 1 deletion(-)
  15. diff --git a/src/avr.c b/src/avr.c
  16. index 6c78ff69..1bc1ffc9 100644
  17. --- a/src/avr.c
  18. +++ b/src/avr.c
  19. @@ -162,7 +162,7 @@ avr_read_header (SF_PRIVATE *psf)
  20. psf->endian = SF_ENDIAN_BIG ;
  21. psf->dataoffset = AVR_HDR_SIZE ;
  22. - psf->datalength = hdr.frames * (hdr.rez / 8) ;
  23. + psf->datalength = (sf_count_t) hdr.frames * (hdr.rez / 8) ;
  24. if (psf->fileoffset > 0)
  25. psf->filelength = AVR_HDR_SIZE + psf->datalength ;
  26. --
  27. 2.39.5