After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 100686 - oggs with id3 tags get recognized as mp3s
oggs with id3 tags get recognized as mp3s
Status: RESOLVED FIXED
Product: gnome-vfs
Classification: Deprecated
Component: MIME and file/program mapping
unspecified
Other Linux
: Normal minor
: ---
Assigned To: gnome-vfs maintainers
gnome-vfs maintainers
Depends on:
Blocks:
 
 
Reported: 2002-12-08 19:38 UTC by Marinus Schraal
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
libgnomevfs/gnome-vfs-mime-magic.c ogg as mp3 patch (438 bytes, patch)
2002-12-08 19:40 UTC, Marinus Schraal
none Details | Review
libgnome-vfs/gnome-vfs-mime-magic.c corrected ogg detection patch (851 bytes, patch)
2002-12-09 13:19 UTC, Marinus Schraal
none Details | Review
more readable version of the patch (716 bytes, patch)
2003-01-20 12:55 UTC, Christophe Fergeau
none Details | Review
corrected short patch (799 bytes, patch)
2003-01-26 02:53 UTC, Marinus Schraal
none Details | Review
New patch. (2.35 KB, patch)
2003-02-18 10:57 UTC, Alexander Larsson
none Details | Review

Description Marinus Schraal 2002-12-08 19:38:44 UTC
oggvorbis files which are tagged with an id3(v2) tags are picked up as
mp3's. It is ofcourse invalid to tag oggs with id3 tags, but it happens a
lot and it doesn't corrupt the file.

I made a small patch which should filter out most cases, besides the case
where the sniffed header part contains the string 'vorbis' for some other
reason (eg. being mentioned in the id3 tag). But i estimated the chance of
that happening minute ;)
Comment 1 Marinus Schraal 2002-12-08 19:40:37 UTC
Created attachment 12852 [details] [review]
libgnomevfs/gnome-vfs-mime-magic.c ogg as mp3 patch
Comment 2 Christophe Fergeau 2002-12-09 09:17:38 UTC
I don't understand this patch. The full code is:
if (strncmp ((char *) sniff_buffer->buffer, "ID3", 3) == 0
        && (sniff_buffer->buffer[3] != 0xffu)
        && (sniff_buffer->buffer[4] != 0xffu)
        && (sniff_buffer->buffer[6] < 0x80u)
        && (sniff_buffer->buffer[7] < 0x80u)
        && (sniff_buffer->buffer[8] < 0x80u)
        && (sniff_buffer->buffer[9] < 0x80u)) {
        return TRUE;
}

ie the first 3 chars of sniff_buffer->buffer are "ID3". How can your 
strcasecmp((char *) sniff_buffer->buffer, "vorbis") be ever == 0 ? And
didn't you invert your test anyway ? didn't you meant 
if (strcasecmp((char *) sniff_buffer->buffer, "vorbis") == 0) ?
Comment 3 Marinus Schraal 2002-12-09 13:17:19 UTC
You're right this won't work as planned, my C is a bit too rusty it
seems i did some wrong assumptions :/

I was thinking of doing it different anyway, so here is a revised
patch. Which looks for the start of a vorbis identification header. I
hope this is better.
Comment 4 Marinus Schraal 2002-12-09 13:19:56 UTC
Created attachment 12870 [details] [review]
libgnome-vfs/gnome-vfs-mime-magic.c corrected ogg detection patch
Comment 5 Christophe Fergeau 2002-12-09 14:42:26 UTC
I think something like if (strcmp(sniff_buffer->buffer[..], "vorbis")
== 0) {...} would be more readable.
Thanks for the updated patch :)
Comment 6 Marinus Schraal 2002-12-09 15:22:56 UTC
Yeah it basicly does that, except for the first byte. *needs to get
his c reference back, where did i leave it*
Comment 7 Christophe Fergeau 2003-01-20 12:55:57 UTC
Created attachment 13697 [details] [review]
more readable version of the patch
Comment 8 Christophe Fergeau 2003-01-20 12:56:19 UTC
How does this patch look ? (and more importantly, is it working ?)
Comment 9 Marinus Schraal 2003-01-20 17:41:41 UTC
It works for me, it's easy to test : just add an id3 tag to a an
ogg/vorbis encoded file. 

And yes this is more readable, i need to fix my C :/
Comment 10 Marinus Schraal 2003-01-26 02:53:02 UTC
Created attachment 13831 [details] [review]
corrected short patch
Comment 11 Marinus Schraal 2003-01-26 02:54:57 UTC
the vorbis header isn't always in the same place, so the sample still
needs to be searched trough. This works for me, your corrected patch
doesn't (spoke a bit too quick there).
Comment 12 Alexander Larsson 2003-02-18 10:57:00 UTC
Created attachment 14410 [details] [review]
New patch.
Comment 13 Alexander Larsson 2003-02-18 10:57:59 UTC
I checked in the attached patch. Can you verify it works?
Comment 14 Marinus Schraal 2003-02-18 14:49:28 UTC
It doesn't work, i remember myself trying with strstr_len at first,
but it didn't work out. The only reason i can think of is that the
buffer may contain chars that the function can't handle (?), but i'm
probably merely showing off my lack of thorough C knowledge here ;)

My last patch has been in Gentoo for quite a while now and works
confirmed fine, altough i can see that it is probably not clean/fast
enough to use.
Comment 15 Alexander Larsson 2003-02-19 09:20:30 UTC
Oh yeah. there are probably null-bytes in the buffer. There goes my
nice fix. :)

I'll change it to your patch then.