diff --git a/postprocessing/janus-pp-rec.c b/postprocessing/janus-pp-rec.c index f87b9f9d131..36eee7fe9cb 100644 --- a/postprocessing/janus-pp-rec.c +++ b/postprocessing/janus-pp-rec.c @@ -709,7 +709,12 @@ int main(int argc, char *argv[]) continue; } /* Only read RTP header */ - bytes = fread(prebuffer, sizeof(char), len > 24 ? 24: len, file); + uint16_t 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 (%i instead %i)\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));