0006-ircam-fix-int-overflow-in-ircam_read_header.patch 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. From 5d5319300587e3d4a146332a2f48674ceb8a0257 Mon Sep 17 00:00:00 2001
  2. From: Alex Stewart <alex.stewart@ni.com>
  3. Date: Wed, 11 Oct 2023 17:43:02 -0400
  4. Subject: [PATCH] ircam: fix int overflow in ircam_read_header()
  5. When reading the IRCAM header, it is possible for the calculated
  6. blockwidth to exceed the bounds of a signed int32.
  7. Use a 64bit sf_count_t to store the blockwidth.
  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/5d5319300587e3d4a146332a2f48674ceb8a0257
  12. Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
  13. ---
  14. src/common.h | 2 +-
  15. src/ircam.c | 10 +++++-----
  16. 2 files changed, 6 insertions(+), 6 deletions(-)
  17. diff --git a/src/common.h b/src/common.h
  18. index cd9ac8b0..01f6ae09 100644
  19. --- a/src/common.h
  20. +++ b/src/common.h
  21. @@ -439,7 +439,7 @@ typedef struct sf_private_tag
  22. sf_count_t datalength ; /* Length in bytes of the audio data. */
  23. sf_count_t dataend ; /* Offset to file tailer. */
  24. - int blockwidth ; /* Size in bytes of one set of interleaved samples. */
  25. + sf_count_t blockwidth ; /* Size in bytes of one set of interleaved samples. */
  26. int bytewidth ; /* Size in bytes of one sample (one channel). */
  27. void *dither ;
  28. diff --git a/src/ircam.c b/src/ircam.c
  29. index 8e7cdba8..3d73ba44 100644
  30. --- a/src/ircam.c
  31. +++ b/src/ircam.c
  32. @@ -171,35 +171,35 @@ ircam_read_header (SF_PRIVATE *psf)
  33. switch (encoding)
  34. { case IRCAM_PCM_16 :
  35. psf->bytewidth = 2 ;
  36. - psf->blockwidth = psf->sf.channels * psf->bytewidth ;
  37. + psf->blockwidth = (sf_count_t) psf->sf.channels * psf->bytewidth ;
  38. psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_PCM_16 ;
  39. break ;
  40. case IRCAM_PCM_32 :
  41. psf->bytewidth = 4 ;
  42. - psf->blockwidth = psf->sf.channels * psf->bytewidth ;
  43. + psf->blockwidth = (sf_count_t) psf->sf.channels * psf->bytewidth ;
  44. psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_PCM_32 ;
  45. break ;
  46. case IRCAM_FLOAT :
  47. psf->bytewidth = 4 ;
  48. - psf->blockwidth = psf->sf.channels * psf->bytewidth ;
  49. + psf->blockwidth = (sf_count_t) psf->sf.channels * psf->bytewidth ;
  50. psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_FLOAT ;
  51. break ;
  52. case IRCAM_ALAW :
  53. psf->bytewidth = 1 ;
  54. - psf->blockwidth = psf->sf.channels * psf->bytewidth ;
  55. + psf->blockwidth = (sf_count_t) psf->sf.channels * psf->bytewidth ;
  56. psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_ALAW ;
  57. break ;
  58. case IRCAM_ULAW :
  59. psf->bytewidth = 1 ;
  60. - psf->blockwidth = psf->sf.channels * psf->bytewidth ;
  61. + psf->blockwidth = (sf_count_t) psf->sf.channels * psf->bytewidth ;
  62. psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_ULAW ;
  63. break ;
  64. --
  65. 2.39.5