Commit 4d3b6eaf authored by Ryan C. Gordon's avatar Ryan C. Gordon

Fixed buffer overflows in resamplers.

I'm not confident this is a complete fix, but I'm not confident the current
 resamplers are really worth keeping at all, either.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404352
parent 1411a41e
This diff is collapsed.
......@@ -537,15 +537,19 @@ ${sym}(SDL_AudioCVT * cvt, SDL_AudioFormat format)
const int dstsize = cvt->len_cvt $lencvtop $multiple;
EOF
my $endcomparison = '!=';
# Upsampling (growing the buffer) needs to work backwards, since we
# overwrite the buffer as we go.
if ($upsample) {
$endcomparison = '>'; # dst > target
print <<EOF;
$fctype *dst = (($fctype *) (cvt->buf + dstsize)) - $channels;
const $fctype *src = (($fctype *) (cvt->buf + cvt->len_cvt)) - $channels;
const $fctype *target = ((const $fctype *) cvt->buf) - $channels;
EOF
} else {
$endcomparison = '<'; # dst < target
print <<EOF;
$fctype *dst = ($fctype *) cvt->buf;
const $fctype *src = ($fctype *) cvt->buf;
......@@ -562,7 +566,7 @@ EOF
}
print <<EOF;
while (dst != target) {
while (dst $endcomparison target) {
EOF
for (my $i = 0; $i < $channels; $i++) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment