[asterisk-dev] bug of mmap return in 1.4.0

Tzafrir Cohen tzafrir.cohen at xorcom.com
Sun Dec 24 01:44:40 MST 2006


On Sun, Dec 24, 2006 at 02:18:03AM -0500, Russell Bryant wrote:
> andy wang wrote:
> >There is a bug on 1.4.0 Chan_iax2.c::try_firmware::1413
> >
> >    fwh = mmap(NULL, stbuf.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
> >    if (!fwh) {
> >        ast_log(LOG_WARNING, "mmap failed: %s\n", strerror(errno));
> >        close(fd);
> >        return -1;
> >    }
> >
> >if mmap fails it will return (-1)
> 
> Nice catch.  This affects 1.2, as well.  I'll go ahead and fix it.

There seem to be quite of few similar cases in chan_zap.c . For
instance, it seems that the caller to zt_get_event (which is a simple
ioctl call wrapper) does not check for the return value of -1.

What should be done in case of an error?

-- 
               Tzafrir Cohen       
icq#16849755                    jabber:tzafrir at jabber.org
+972-50-7952406           mailto:tzafrir.cohen at xorcom.com       
http://www.xorcom.com  iax:guest at local.xorcom.com/tzafrir


More information about the asterisk-dev mailing list