Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions extractaudio/eaud_pcap.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ eaud_pcap_dissect(unsigned char *bp, size_t blen, int network,
}
memcpy(&family, &pcp->null.family, sizeof(family));
memcpy(&incl_len, &pcp->null.pcaprec_hdr.incl_len, sizeof(incl_len));
if (incl_len > blen - sizeof(pcaprec_hdr_t)) {
return (PCP_DSCT_TRNK);
}
if (family != AF_INET) {
dp->pcap_hdr_len = sizeof(pcaprec_hdr_t) + incl_len;
return (PCP_DSCT_UNKN);
Expand All @@ -82,6 +85,9 @@ eaud_pcap_dissect(unsigned char *bp, size_t blen, int network,
}
memcpy(&ether_type, &pcp->en10t.ether.type, sizeof(ether_type));
memcpy(&incl_len, &pcp->en10t.pcaprec_hdr.incl_len, sizeof(incl_len));
if (incl_len > blen - sizeof(pcaprec_hdr_t)) {
return (PCP_DSCT_TRNK);
}
if (ether_type != ETHERTYPE_INET) {
dp->pcap_hdr_len = sizeof(pcaprec_hdr_t) + incl_len;
return (PCP_DSCT_UNKN);
Expand Down
15 changes: 15 additions & 0 deletions tests/extractaudio/badargs
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,18 @@ ${EXTRACTAUDIO} -D pcm_16 -C 0.5 extractaudio/call1_alaw ${wfile}
reportifnotfail "extractaudio start with bad argumens: -D pcm_16 -C 0.5"
test ! -e ${wfile}
report "${wfile} is removed"

# A PCAP record whose incl_len runs past the end of the file has to be
# rejected, not read.
rbase="badargs.trunc"
dd if=extractaudio/call1_g722_srtp.a.rtp of=${rbase}.a.rtp bs=264 count=1 \
2>/dev/null
# incl_len = 0x10000000, RTP P bit set so that the parser reads the last byte
printf '\000\000\000\020' | dd of=${rbase}.a.rtp bs=1 seek=32 conv=notrunc \
2>/dev/null
printf '\240' | dd of=${rbase}.a.rtp bs=1 seek=82 conv=notrunc 2>/dev/null
cp ${rbase}.a.rtp ${rbase}.o.rtp
${EXTRACTAUDIO} ${rbase} ${rbase}.wav >/dev/null 2>&1
test ${?} -eq 1
report "extractaudio rejects a truncated PCAP record"
rm -f ${rbase}.a.rtp ${rbase}.o.rtp ${rbase}.wav
Loading