Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: prevent borked generated audio file if meetecho header is sent with no RTP data next #2356

Merged
merged 1 commit into from
Sep 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 < (int)sizeof(gint64)) {
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