0013-Fix-oggdec-crash-hang-Don-t-ignore-stream-errors.patch 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. From: =?utf-8?q?Martin_Stegh=C3=B6fer?= <martin@steghoefer.eu>
  2. Date: Fri, 12 Dec 2014 18:21:08 +0100
  3. Subject: Fix oggdec crash/hang: Don't ignore stream errors
  4. oggdec treats all negative return values coming from ov_read
  5. as OV_HOLE errors and therefore as recoverable. So even in the
  6. case of fatal errors it keeps on calling ov_read, which may
  7. either crash (libvorbis' data structures may be uninitialized)
  8. or simply not progress and therefore trap oggdec in an
  9. infinite loop.
  10. Fix this by distinguishing between recoverable and
  11. non-recoverable errors. In the case of fatal errors, exit
  12. gracefully with an error message. The error string is
  13. "borrowed" from ogg123 and therefore already translated into
  14. several languages.
  15. Bug-Debian: https://bugs.debian.org/772978
  16. Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/vorbis-tools/+bug/629135
  17. Forwarded: https://trac.xiph.org/ticket/2148
  18. ---
  19. oggdec/oggdec.c | 15 +++++++++++----
  20. 1 file changed, 11 insertions(+), 4 deletions(-)
  21. diff --git a/oggdec/oggdec.c b/oggdec/oggdec.c
  22. index a99f95d..16f87ac 100644
  23. --- a/oggdec/oggdec.c
  24. +++ b/oggdec/oggdec.c
  25. @@ -310,12 +310,19 @@ static int decode_file(FILE *in, FILE *out, char *infile, char *outfile)
  26. }
  27. }
  28. - if(ret < 0 ) {
  29. - if( !quiet ) {
  30. - fprintf(stderr, _("WARNING: hole in data (%d)\n"), ret);
  31. - }
  32. + if(ret == OV_HOLE) {
  33. + if(!quiet) {
  34. + fprintf(stderr, _("WARNING: hole in data (%d)\n"), ret);
  35. + }
  36. continue;
  37. }
  38. + else if(ret < 0) {
  39. + if(!quiet) {
  40. + fprintf(stderr, _("=== Vorbis library reported a stream error.\n"));
  41. + }
  42. + ov_clear(&vf);
  43. + return 1;
  44. + }
  45. if(channels > 2 && !raw) {
  46. /* Then permute! */