RTSP/SDP: Fix parsing error for H264:sprop-parameter-sets

Rework the method verifying  if there are more data in packed attribute
New version checks if there are any non-zero bits after the current bit in the
packet. If it sees some non-zero bits - that means there is some data in the
packet. If there are zero bits only - that means there is no more data in the
packet.
Changes affect RTSP/SDP dissector and they are specific for
SDP media attribute (a) fmtp/sprop-parameter-sets for H264 protocol

Bug: 16322
Change-Id: Ic4768c56f16b79cbf2ccac8a9736f8fa15043224
Reviewed-on: https://code.wireshark.org/review/36899
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Sergey Bogdanov 2020-04-27 10:24:35 +03:00 committed by Anders Broman
parent 56e9110e09
commit 5f80801add
1 changed files with 30 additions and 22 deletions

View File

@ -806,41 +806,49 @@ dissect_h264_exp_golomb_code(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint
/* This function is adapted to parsing NAL units from SDP data where the
* base64 coding may add extra padding
* Returns TRUE if there is a non-zero bit in remaining of tvb (skipping the current bit)
* FALSE if the rest of the tvb is zeros
*/
static gboolean
more_rbsp_data(proto_tree *tree _U_, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset)
{
int offset;
int remaining_length;
int last_one_bit;
guint8 b = 0;
int current_bit_offset;
int byte_offset;
int tvb_length;
int significant_bits_mask;
int i;
guint8 current_byte;
/* XXX might not be the best way of doing things but:
* Serch from the end of the tvb for the first '1' bit
* assuming that it's the RTBSP stop bit
* Search in the tvb for the first '1' bit
* assuming that it's the RTBSP stop bit or
* some data representation
*/
/*Skip current treating bit*/
current_bit_offset = bit_offset + 1;
/*Mask for non processed bits of the current byte*/
significant_bits_mask = (1 << (8 - (current_bit_offset & 0x07))) - 1;
/* Set offset to the byte we are treating */
offset = bit_offset>>3;
remaining_length = tvb_reported_length_remaining(tvb, offset);
/* If there is more then 2 bytes left there *should* be more data */
if (remaining_length>2) {
return TRUE;
}
/* Start from last bit */
last_one_bit = (tvb_reported_length(tvb) << 3);
byte_offset = current_bit_offset >> 3;
for (b = 0; !b; ) {
last_one_bit--;
b = tvb_get_bits8(tvb, last_one_bit, 1);
tvb_length = tvb_reported_length(tvb);
for (i = byte_offset; i < tvb_length; i++) {
current_byte = tvb_get_guint8(tvb, i);
if ((current_byte & significant_bits_mask) != 0) {
return TRUE;
}
/* For the rest of bytes every bits are significant*/
significant_bits_mask = 0xFF;
}
if (last_one_bit == bit_offset) {
return FALSE;
}
return TRUE;
return FALSE;
}
static int