Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 85100 - mp3info not correctly detecting frame start when probing for VBR
Summary: mp3info not correctly detecting frame start when probing for VBR
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High major
Assignee: Gentoo Sound Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-13 08:56 UTC by Ben Bennett
Modified: 2005-08-13 06:04 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
cast.patch (cast.patch,449 bytes, patch)
2005-08-13 06:03 UTC, Tony Vroon (RETIRED)
Details | Diff
sanity-checks.patch (sanity-checks.patch,487 bytes, patch)
2005-08-13 06:03 UTC, Tony Vroon (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ben Bennett 2005-03-13 08:56:29 UTC
The problem is that mp3info is not correctly detecting an mp3 frame
start when probing to see if the file is VBR when determining the
rate.  The issue is that the bitrate is 0xf which is one of the
illegal values and does not exist in the lookup table.  The math done
to the value ends up with a lookup offset of -1.  On older gccs that
was not a fatal error, but gave back something unexpected.  So on
older versions of gcc it calculates things incorrectly, on newer ones
it crashes.


Reproducible: Always
Steps to Reproduce:
1. Run mp3info on a mp3 with some junk on the front



Actual Results:  
mp3info crashes

Expected Results:  
Give information about the mp3.

The following patch fixes it to include some more robust frame checks.

fiji@apollo:~/mp3info> cat sanity_patch.diff
--- mp3info-0.8.4/mp3tech.c     2001-07-16 05:56:52.000000000 -0400
+++ new/mp3tech.c       2004-12-08 11:38:57.759884705 -0500
@@ -243,6 +243,11 @@
     header->copyright=(buffer[3] >> 3) & 0x1;
     header->original=(buffer[3] >> 2) & 0x1;
     header->emphasis=(buffer[3]) & 0x3;
+
+    /* Final sanity checks: bitrate can not be 1111, frequency can not be 11 */
+    if (header->bitrate == 0x0F || header->freq == 0x3) {
+      return 0;
+    }

     return ((fl=frame_length(header)) >= MIN_FRAME_SIZE ? fl : 0);
 }



As a bonus diff, the following patch casts the pointer arithmetic to
avoid a compiler warning.

+++ new/textfunc.c      2004-12-08 12:34:13.412457426 -0500
@@ -235,7 +235,8 @@
                if(*code) {
                        modlen=code-percent+1;
                        if(modlen > 1000) {
-                               printf("Format modifier beginning at position %d too
+long!\n",percent-format);
+                               printf("Format modifier beginning at position %d
too long!\n",
+                                      (int)(percent-format));
                                exit(5);
                        }
                        strncpy(mod,percent,modlen);
Comment 1 Carsten Lohrke (RETIRED) gentoo-dev 2005-03-13 15:05:19 UTC
Ben, please attach patches as plain text, don't inline.
Comment 2 Tony Vroon (RETIRED) gentoo-dev 2005-08-13 06:03:18 UTC
Created attachment 65831 [details, diff]
cast.patch
Comment 3 Tony Vroon (RETIRED) gentoo-dev 2005-08-13 06:03:36 UTC
Created attachment 65832 [details, diff]
sanity-checks.patch
Comment 4 Tony Vroon (RETIRED) gentoo-dev 2005-08-13 06:04:53 UTC
Not sure what happened to these patches, there weren't only inline, but they
failed to apply. I have rediffed them manually. (Seems as if you amended them by
hand later, please don't do that).
This is in portage.