Skip to content

Commit

Permalink
Bugfix: prevent borked generated audio file if meetecho header is pre…
Browse files Browse the repository at this point in the history
…sent with no RTP data next
  • Loading branch information
SamyCookie committed Sep 9, 2020
1 parent f3eb0d7 commit 05a804a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion postprocessing/janus-pp-rec.c
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ int main(int argc, char *argv[])
times_resetted = 0;
post_reset_pkts = 0;
uint64_t max32 = UINT32_MAX;
uint16_t rtp_header_len;
/* Start loop */
while(working && offset < fsize) {
/* Read frame header */
Expand Down Expand Up @@ -679,6 +680,10 @@ int main(int argc, char *argv[])
/* Things are simpler for data, no reordering is needed: start by the data time */
gint64 when = 0;
bytes = fread(&when, sizeof(gint64), 1, file);
if (bytes < 1) {
JANUS_LOG(LOG_WARN, "Missing data timestamp header");
break;
}
when = ntohll(when);
offset += sizeof(gint64);
len -= sizeof(gint64);
Expand Down Expand Up @@ -709,7 +714,12 @@ int main(int argc, char *argv[])
continue;
}
/* Only read RTP header */
bytes = fread(prebuffer, sizeof(char), len > 24 ? 24: len, file);
rtp_header_len = len > 24 ? 24: len;
bytes = fread(prebuffer, sizeof(char), rtp_header_len, file);
if (bytes < rtp_header_len) {
JANUS_LOG(LOG_WARN, "Missing RTP packet header data (%d instead %"SCNu16")\n", bytes, rtp_header_len);
break;
}
janus_pp_rtp_header *rtp = (janus_pp_rtp_header *)prebuffer;
JANUS_LOG(LOG_VERB, " -- RTP packet (ssrc=%"SCNu32", pt=%"SCNu16", ext=%"SCNu16", seq=%"SCNu16", ts=%"SCNu32")\n",
ntohl(rtp->ssrc), rtp->type, rtp->extension, ntohs(rtp->seq_number), ntohl(rtp->timestamp));
Expand Down

0 comments on commit 05a804a

Please sign in to comment.