Cross-Platform build scripts for audio plugins
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
1.2KB

  1. Description: Fix heap buffer overflows when writing strings in binheader
  2. Author: Jörn Heusipp <osmanx@problemloesungsmaschine.de>
  3. Origin: upstream
  4. Applied-Upstream: cf7a8182c2642c50f1cf90dddea9ce96a8bad2e8
  5. Last-Update: 2017-07-12
  6. ---
  7. This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
  8. --- libsndfile.orig/src/common.c
  9. +++ libsndfile/src/common.c
  10. @@ -675,15 +675,15 @@
  11. /* Write a C string (guaranteed to have a zero terminator). */
  12. strptr = va_arg (argptr, char *) ;
  13. size = strlen (strptr) + 1 ;
  14. - size += (size & 1) ;
  15. - if (psf->header.indx + (sf_count_t) size >= psf->header.len && psf_bump_header_allocation (psf, 16))
  16. + if (psf->header.indx + 4 + (sf_count_t) size + (sf_count_t) (size & 1) > psf->header.len && psf_bump_header_allocation (psf, 4 + size + (size & 1)))
  17. return count ;
  18. if (psf->rwf_endian == SF_ENDIAN_BIG)
  19. - header_put_be_int (psf, size) ;
  20. + header_put_be_int (psf, size + (size & 1)) ;
  21. else
  22. - header_put_le_int (psf, size) ;
  23. + header_put_le_int (psf, size + (size & 1)) ;
  24. + size += (size & 1) ;
  25. memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size) ;
  26. psf->header.indx += size ;
  27. psf->header.ptr [psf->header.indx - 1] = 0 ;