0006-Add-sampling-rate-sanity-check-to-avoid-crash.patch 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. From: =?utf-8?q?Martin_Stegh=C3=B6fer?= <martin@steghoefer.eu>
  2. Date: Mon, 27 Oct 2014 19:51:13 +0100
  3. Subject: Add sampling rate sanity check to avoid crash.
  4. Bug-Debian: https://bugs.debian.org/716613
  5. Forwarded: https://trac.xiph.org/ticket/2078
  6. Input files with sampling rate 0 are useless and can make oggenc crash because neither oggenc itself nor libvorbis are prepared for this case. A sanity check lets the program refuse those inputs gracefully without crash.
  7. ---
  8. oggenc/oggenc.c | 9 +++++++++
  9. 1 file changed, 9 insertions(+)
  10. diff --git a/oggenc/oggenc.c b/oggenc/oggenc.c
  11. index 5c36fea..6a6d8fe 100644
  12. --- a/oggenc/oggenc.c
  13. +++ b/oggenc/oggenc.c
  14. @@ -272,6 +272,15 @@ int main(int argc, char **argv)
  15. errors++;
  16. continue;
  17. }
  18. +
  19. + if(enc_opts.rate <= 0)
  20. + {
  21. + fprintf(stderr, _("ERROR: Input file \"%s\" has invalid sampling rate\n"), infiles[i]?infiles[i]:"(stdin)");
  22. + if(closein)
  23. + fclose(in);
  24. + errors++;
  25. + continue;
  26. + }
  27. /* Ok. We can read the file - so now open the output file */