diff options
author | Matthew Jordan <mjordan@digium.com> | 2013-04-14 02:35:04 +0000 |
---|---|---|
committer | Matthew Jordan <mjordan@digium.com> | 2013-04-14 02:35:04 +0000 |
commit | 51117442149cbe9b0f7e25487f22a970bffda682 (patch) | |
tree | 3b426611a3b42e4ffb7f103957dfde6b96db1ab2 /channels/chan_alsa.c | |
parent | a7c5183d671a8a5769bb302bb71da67350771456 (diff) |
Don't attempt to create a voice frame on a read error
Prior to this patch, a read error in snd_pcm_readi would still be treated as a
nominal result when constructing a voice frame from the expected data. Since
the value returned is negative, as opposed to the number of samples read,
this could result in a crash. With this patch, we now return a null frame
when a read error is detected.
Note that the patch on ASTERISK-21329 was modified slightly for this commit,
in that we bail immediately on detecting the read error, rather than bypassing
the construction of the voice frame.
(closes issue ASTERISK-21329)
Reported by: Keiichiro Kawasaki
patches:
chan_alsa.diff uploaded by kawasaki (License 6489)
........
Merged revisions 385633 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 385634 from http://svn.asterisk.org/svn/asterisk/branches/11
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@385635 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_alsa.c')
-rw-r--r-- | channels/chan_alsa.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/channels/chan_alsa.c b/channels/chan_alsa.c index c43decb1c..7f54d6cfa 100644 --- a/channels/chan_alsa.c +++ b/channels/chan_alsa.c @@ -483,6 +483,13 @@ static struct ast_frame *alsa_read(struct ast_channel *chan) } else if (r < 0) { ast_log(LOG_ERROR, "Read error: %s\n", snd_strerror(r)); } + + /* Return NULL frame on error */ + if (r < 0) { + ast_mutex_unlock(&alsalock); + return &f; + } + /* Update positions */ readpos += r; left -= r; |