1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-09-29 04:25:55 -04:00

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.

svn path=/trunk/icecast/; revision=5817
This commit is contained in:
Michael Smith 2004-02-10 04:29:54 +00:00
parent 6128c0631c
commit 3d9d45c488

View File

@ -326,12 +326,21 @@ static int format_mp3_get_buffer(format_plugin_t *self, char *data,
StreamTitle=' and the closing '; (but only if there's StreamTitle=' and the closing '; (but only if there's
enough data for it to be correctly formatted) */ enough data for it to be correctly formatted) */
if(state->metadata_length >= 15) { 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 - state->metadata = malloc(state->metadata_length -
15 + 1); 15 + 1);
memcpy(state->metadata, memcpy(state->metadata,
state->metadata_buffer + 13, state->metadata_buffer + 13,
state->metadata_length - 15); 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); free(state->metadata_buffer);
} }
else else