0011-pcm-fix-int-overflow-in-pcm_init.patch 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. From 09f8f8d5544d98a5a2d28504c02314a2a816ac37 Mon Sep 17 00:00:00 2001
  2. From: Alex Stewart <alex.stewart@ni.com>
  3. Date: Tue, 17 Oct 2023 11:57:23 -0400
  4. Subject: [PATCH] pcm: fix int overflow in pcm_init()
  5. Cast the int-sized bytewidth variable to a long-sized sf_count_t type
  6. prior to calculating the blockwidth, to provide the calculation with
  7. enough numeric space and sf_count_t is the final typing regardless.
  8. CVE: CVE-2022-33065
  9. Fixes: https://github.com/libsndfile/libsndfile/issues/833
  10. Signed-off-by: Alex Stewart <alex.stewart@ni.com>
  11. Upstream: https://github.com/libsndfile/libsndfile/commit/09f8f8d5544d98a5a2d28504c02314a2a816ac37
  12. Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
  13. ---
  14. src/pcm.c | 2 +-
  15. 1 file changed, 1 insertion(+), 1 deletion(-)
  16. diff --git a/src/pcm.c b/src/pcm.c
  17. index bdf46183..a42e4868 100644
  18. --- a/src/pcm.c
  19. +++ b/src/pcm.c
  20. @@ -127,7 +127,7 @@ pcm_init (SF_PRIVATE *psf)
  21. return SFE_INTERNAL ;
  22. } ;
  23. - psf->blockwidth = psf->bytewidth * psf->sf.channels ;
  24. + psf->blockwidth = (sf_count_t) psf->bytewidth * psf->sf.channels ;
  25. if ((SF_CODEC (psf->sf.format)) == SF_FORMAT_PCM_S8)
  26. chars = SF_CHARS_SIGNED ;
  27. --
  28. 2.39.5