chan_dahdi: Fix crash during caller ID read

Asterisk will sometimes core dump during caller id read on analog
channels due to a negative return value from the read() in
my_get_callerid that slips through as a negative length argument to
callerid_feed() if the errno returned by DAHDI is ELAST. This change
ensures that the negative return is treated properly even when it is
ELAST.

(closes issue ASTERISK-22746)
Reported by: Michael Walton
Patches:
    chan_dahdi_cid_crash_fix.r401410.patch uploaded by Michael Walton (License 6502)
........

Merged revisions 402708 from http://svn.asterisk.org/svn/asterisk/branches/1.8


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/11@402709 65c4cc65-6c06-0410-ace0-fbb531ad65f3
changes/61/61/1
Kinsey Moore 12 years ago
parent 6d85bb82e1
commit c5c9050b89

@ -1800,12 +1800,9 @@ static int my_get_callerid(void *pvt, char *namebuf, char *numbuf, enum analog_e
* a failure and die, and returning 2 means no event was received. */
res = read(p->subs[index].dfd, buf, sizeof(buf));
if (res < 0) {
if (errno != ELAST) {
ast_log(LOG_WARNING, "read returned error: %s\n", strerror(errno));
callerid_free(p->cs);
return -1;
}
}
if (analog_p->ringt > 0) {
if (!(--analog_p->ringt)) {

Loading…
Cancel
Save