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
2 changes: 1 addition & 1 deletion extractaudio/decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ decode_frame(struct decoder_stream *dp, int16_t *obuf, unsigned char *ibuf,
if (ibytes < 33) {
return (-1);
}
for (obytes = 0; ibytes > 0 && obytes <= obytes_max - 320; ibytes -= 33) {
for (obytes = 0; ibytes >= 33 && obytes <= obytes_max - 320; ibytes -= 33) {
gsm_decode(dp->ctx_gsm, ibuf, obuf);
ibuf += 33;
obuf += 160;
Expand Down
4 changes: 3 additions & 1 deletion tests/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ host_triplet = @host@
@ENABLE_BASIC_TESTS_TRUE@ extractaudio/extractaudio1 \
@ENABLE_BASIC_TESTS_TRUE@ extractaudio/scan \
@ENABLE_BASIC_TESTS_TRUE@ extractaudio/encopts \
@ENABLE_BASIC_TESTS_TRUE@ extractaudio/gsm_partial \
@ENABLE_BASIC_TESTS_TRUE@ startstop/goodargs startstop/badargs \
@ENABLE_BASIC_TESTS_TRUE@ startstop/startstop1 \
@ENABLE_BASIC_TESTS_TRUE@ startstop/nodebug \
Expand Down Expand Up @@ -438,7 +439,8 @@ EXTRA_DIST = $(am__append_3) $(am__append_5) $(am__append_9) \
@ENABLE_BASIC_TESTS_TRUE@ *.mono.*.rlog *.stereo.*.rlog *.scan.rlog *.scan.tout \
@ENABLE_BASIC_TESTS_TRUE@ *.stereo.*.raw *.stereo.*.raw.tout *.nbcheck.*.raw.txt \
@ENABLE_BASIC_TESTS_TRUE@ *.encopts.*.ogg *.encopts.*.ogg.tout *.encopts.*.ogg.rlog \
@ENABLE_BASIC_TESTS_TRUE@ encopts.probe.ogg badargs.clevel.wav badargs.out.ogg
@ENABLE_BASIC_TESTS_TRUE@ encopts.probe.ogg badargs.clevel.wav badargs.out.ogg \
@ENABLE_BASIC_TESTS_TRUE@ gsm_partial.*.raw gsm_partial.*.raw.tout gsm_partial.*.raw.rlog

@ENABLE_BASIC_TESTS_TRUE@startstop_EXTRA_DIST = startstop
@ENABLE_BASIC_TESTS_TRUE@startstop_CLEANFILES = startstop*.rout startstop*.rlog
Expand Down
5 changes: 3 additions & 2 deletions tests/extractaudio/Makefile.ami
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ extractaudio_CLEANFILES = *.mono.*.wav *.stereo.*.wav *.mono.*.wav.tout \
*.mono.*.rlog *.stereo.*.rlog *.scan.rlog *.scan.tout \
*.stereo.*.raw *.stereo.*.raw.tout *.nbcheck.*.raw.txt \
*.encopts.*.ogg *.encopts.*.ogg.tout *.encopts.*.ogg.rlog \
encopts.probe.ogg badargs.clevel.wav badargs.out.ogg
encopts.probe.ogg badargs.clevel.wav badargs.out.ogg \
gsm_partial.*.raw gsm_partial.*.raw.tout gsm_partial.*.raw.rlog
TESTS += extractaudio/badargs extractaudio/extractaudio1 extractaudio/scan \
extractaudio/encopts
extractaudio/encopts extractaudio/gsm_partial
CLEANFILES += ${extractaudio_CLEANFILES}
EXTRA_DIST += ${extractaudio_EXTRA_DIST}
Binary file added tests/extractaudio/corrupted_gsm.a.rtp
Binary file not shown.
Binary file added tests/extractaudio/corrupted_gsm.o.rtp
Binary file not shown.
26 changes: 26 additions & 0 deletions tests/extractaudio/gsm_partial
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh

# A GSM packet whose payload is not a multiple of 33 bytes has to be decoded
# up to the last whole frame, the trailing remainder has to be ignored.
#
# corrupted_gsm is call1_gsm with an extra byte appended to some of the
# packets (34 byte payload), so the decoded audio has to match that of the
# original recording exactly. Before the fix the decoder went on past the end
# of the packet, producing garbage and reading out of bounds.

BASEDIR="`dirname "${0}"`/.."
. "${BASEDIR}/functions"

for rname in call1_gsm corrupted_gsm
do
wfile="gsm_partial.${rname}.raw"
rm -f "${wfile}"
${EXTRACTAUDIO} -F raw -D pcm_16 "${BASEDIR}/extractaudio/${rname}" \
"${wfile}" 2>"${wfile}.rlog" >"${wfile}.tout"
report "${EXTRACTAUDIO} ${rname} -> ${wfile}"
test -s "${wfile}"
report "checking that ${wfile} is not empty"
done

cmp gsm_partial.call1_gsm.raw gsm_partial.corrupted_gsm.raw
report "checking that corrupted_gsm decodes the same as call1_gsm"
Loading