forked from osmocom/wireshark
mpeg: handle the presence of an image in the ID3v2 header.
Fixes #17985.
This commit is contained in:
parent
3f9fdc373e
commit
80d0283341
|
@ -163,7 +163,22 @@ mpeg_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
packet_size = mpeg_resync(fh, err);
|
if ((n & 0xffffff00) == 0x49443300) {
|
||||||
|
/* We have an ID3v2 header; read the size */
|
||||||
|
if (file_seek(fh, 6, SEEK_CUR, err) == -1)
|
||||||
|
return FALSE;
|
||||||
|
if (!wtap_read_bytes_or_eof(fh, &n, sizeof n, err, err_info))
|
||||||
|
return FALSE;
|
||||||
|
if (file_seek(fh, -(gint64)(6+sizeof(n)), SEEK_CUR, err) == -1)
|
||||||
|
return FALSE;
|
||||||
|
n = g_ntohl(n);
|
||||||
|
|
||||||
|
/* ID3v2 size does not include the 10-byte header */
|
||||||
|
packet_size = decode_synchsafe_int(n) + 10;
|
||||||
|
} else {
|
||||||
|
packet_size = mpeg_resync(fh, err);
|
||||||
|
}
|
||||||
|
|
||||||
if (packet_size == 0)
|
if (packet_size == 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,6 +81,33 @@ mpa_padding(const struct mpa *mpa)
|
||||||
return(mpa->padding ? mpa_padding_data[mpa_layers[mpa->layer]] : 0);
|
return(mpa->padding ? mpa_padding_data[mpa_layers[mpa->layer]] : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Decode an ID3v2 synchsafe integer.
|
||||||
|
* See https://id3.org/id3v2.4.0-structure section 6.2.
|
||||||
|
*/
|
||||||
|
guint32
|
||||||
|
decode_synchsafe_int(guint32 input)
|
||||||
|
{
|
||||||
|
guint32 value;
|
||||||
|
|
||||||
|
/* High-order byte */
|
||||||
|
value = (input >> 24) & 0x7f;
|
||||||
|
/* Shift the result left to make room for the next 7 bits */
|
||||||
|
value <<= 7;
|
||||||
|
|
||||||
|
/* Now OR in the 2nd byte */
|
||||||
|
value |= (input >> 16) & 0x7f;
|
||||||
|
value <<= 7;
|
||||||
|
|
||||||
|
/* ... and the 3rd */
|
||||||
|
value |= (input >> 8) & 0x7f;
|
||||||
|
value <<= 7;
|
||||||
|
|
||||||
|
/* For the 4th byte don't do the shift */
|
||||||
|
value |= input & 0x7f;
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
||||||
*
|
*
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#ifndef MPA_H
|
#ifndef MPA_H
|
||||||
#define MPA_H 1
|
#define MPA_H 1
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
#include "ws_symbol_export.h"
|
#include "ws_symbol_export.h"
|
||||||
|
|
||||||
struct mpa {
|
struct mpa {
|
||||||
|
@ -71,6 +72,8 @@ WS_DLL_PUBLIC
|
||||||
unsigned int mpa_frequency(const struct mpa *);
|
unsigned int mpa_frequency(const struct mpa *);
|
||||||
WS_DLL_PUBLIC
|
WS_DLL_PUBLIC
|
||||||
unsigned int mpa_padding(const struct mpa *);
|
unsigned int mpa_padding(const struct mpa *);
|
||||||
|
WS_DLL_PUBLIC
|
||||||
|
guint32 decode_synchsafe_int(guint32);
|
||||||
|
|
||||||
#define MPA_DATA_BYTES(mpa) (mpa_bitrate(mpa) * mpa_samples(mpa) \
|
#define MPA_DATA_BYTES(mpa) (mpa_bitrate(mpa) * mpa_samples(mpa) \
|
||||||
/ mpa_frequency(mpa) / 8)
|
/ mpa_frequency(mpa) / 8)
|
||||||
|
|
Loading…
Reference in New Issue