]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Don't attempt to create a voice frame on a read error
authorMatthew Jordan <mjordan@digium.com>
Sun, 14 Apr 2013 02:21:30 +0000 (02:21 +0000)
committerMatthew Jordan <mjordan@digium.com>
Sun, 14 Apr 2013 02:21:30 +0000 (02:21 +0000)
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)

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@385633 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_alsa.c

index 8a3c1198b7b636371b020370b2368941330fe42f..2bbc74d6a21513c8af80b9c1615239603d715f42 100644 (file)
@@ -482,6 +482,13 @@ static struct ast_frame *alsa_read(struct ast_channel *chan)
        } else if (r >= 0) {
                off -= r;
        }
+
+       /* Return NULL frame on error */
+       if (r < 0) {
+               ast_mutex_unlock(&alsalock);
+               return &f;
+       }
+
        /* Update positions */
        readpos += r;
        left -= r;