On Tue, Jul 31, 2012 at 10:06:33AM -0700, Ansis Atteka wrote: > On Mon, Jul 30, 2012 at 3:18 PM, Ben Pfaff <b...@nicira.com> wrote: > > > It will acquire its first user in an upcoming commit. > > > > Signed-off-by: Ben Pfaff <b...@nicira.com>
... > > +xreadlink(const char *filename) > > +{ > > + size_t size; > > > + > > + for (size = 64; ; size *= 2) { > > + char *buf = xmalloc(size); > > + int retval = readlink(filename, buf, size); > > + int error = errno; > > + > > + if (retval >= 0 && retval < size) { > > + buf[retval] = '\0'; > > + return buf; > > + } > > + > > + free(buf); > > + if (retval < size) { > > > Shouldn't size be of type ssize_t instead? Otherwise this could loop > forever, if readlink() returned -1. Good catch. Thank you, that's a nasty bug. I think that changing (retval < size) to (retval < 0) fixes the problem too. What do you think? _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev