[xiph-cvs] cvs commit: icecast/src format_mp3.c

Michael Smith msmith at xiph.org
Mon Feb 9 20:29:54 PST 2004



msmith      04/02/09 23:29:54

  Modified:    src      format_mp3.c
  Log:
  Another fix: the length of the _string_ is not the same as the metadata length
  (the metadata is null-padded out to a multiple of 16 bytes), so we have to deal
  with that.

Revision  Changes    Path
1.31      +10 -1     icecast/src/format_mp3.c

Index: format_mp3.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/format_mp3.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- format_mp3.c	10 Feb 2004 04:20:43 -0000	1.30
+++ format_mp3.c	10 Feb 2004 04:29:54 -0000	1.31
@@ -326,12 +326,21 @@
                            StreamTitle=' and the closing '; (but only if there's
                            enough data for it to be correctly formatted) */
                         if(state->metadata_length >= 15) {
+                            /* This is overly complex because the 
+                               metadata_length is the length of the actual raw
+                               data, but the (null-terminated) string is going
+                               to be shorter than this, and we can't trust that
+                               the raw data doesn't have other embedded-nulls */
+                            int stringlength;
+                            
                             state->metadata = malloc(state->metadata_length -
                                     15 + 1);
                             memcpy(state->metadata, 
                                     state->metadata_buffer + 13, 
                                     state->metadata_length - 15);
-                            state->metadata[state->metadata_length - 15] = 0;
+                            stringlength = strlen(state->metadata);
+                            if(stringlength > 2)
+                                state->metadata[stringlength - 2] = 0;
                             free(state->metadata_buffer);
                         }
                         else

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list