mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-24 05:02:10 +00:00
[core] avoid overflow when channel muxing
This commit is contained in:
committed by
Andrey Volk
parent
a28436deb7
commit
c2e80ea1e3
@@ -589,15 +589,17 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_write(switch_file_handle_t *fh,
|
||||
|
||||
|
||||
if (fh->real_channels != fh->channels && !switch_test_flag(fh, SWITCH_FILE_NOMUX)) {
|
||||
int need = *len * 2 * fh->real_channels;
|
||||
int need = *len * 2 * (fh->real_channels > fh->channels ? fh->real_channels : fh->channels);
|
||||
|
||||
if (need > fh->muxlen) {
|
||||
fh->muxbuf = realloc(fh->muxbuf, need);
|
||||
switch_assert(fh->muxbuf);
|
||||
fh->muxlen = need;
|
||||
memcpy(fh->muxbuf, data, fh->muxlen);
|
||||
data = fh->muxbuf;
|
||||
}
|
||||
|
||||
if (fh->muxbuf) {
|
||||
memcpy(fh->muxbuf, data, *len * 2);
|
||||
data = fh->muxbuf;
|
||||
}
|
||||
|
||||
switch_mux_channels((int16_t *) data, *len, fh->real_channels, fh->channels);
|
||||
|
||||
Reference in New Issue
Block a user