From: Carlo M. A. B. <ca...@sa...> - 2011-02-28 02:02:50
|
On Thu, Feb 24, 2011 at 10:44:58PM +0000, Kostas Georgiou wrote: > On Thu, Feb 24, 2011 at 12:25:16PM +0000, Carlo Marcelo Arenas Belon wrote: > > > On Wed, Feb 23, 2011 at 09:42:56AM -0800, Bernard Li wrote: > > > > > > 123 read: > > > 124 read_len = read(fd, db, buflen); > > > 125 if (read_len <= 0) > > > 126 { > > > 127 if (errno == EINTR) > > > 128 goto read; > > > 129 err_ret("slurpfile() read() error on file %s", filename); > > > 130 close(fd); > > > 131 return SYNAPSE_FAILURE; > > > 132 } > > > > this code is not relevant as it is only called when EINTR is received > > because a signal interrupts the read call (very unlikely) > > Shouldn't this be "if (read_len < 0)", a return of zero from read is > possible (EOF for example). If slurpfile is called with buffer=NULL and > buffsize equal or a multiple of the file size then we get > SYNAPSE_FAILURE. The errno check will be against an old value of errno > in this which makes it more likely to hit (still very unlikely though :) > and then we have an infinite loop... good point, eventhough I would like to think that errno will be reset by the read call and avoid the infinite loop anyway. Committed revision 2494 Carlo |