[gnet] off by one error in gnet_iochannel_readline_strdup



Simon Li discovered an off-by-one bug in readline_strdup.  One byte of
garbage is put in the buffer when the buffer is resized (only happens if
the string is more than 80 characters).  The new code is in CVS.  The
workaround is to copy the whole function from CVS into your program.

      if (n >= len)
        {
          len *= 2;
          buf = g_realloc(buf, len);
          ptr = buf + n - 1;			/* WAS ptr = buf + n; */
        }

David


-- 
      __          _    __  David Helder - University of Michigan
  ___/ /__ __  __(_)__/ /  dhelder umich edu
 / _  / _ `/ |/ / / _  /   http://www.eecs.umich.edu/~dhelder
 |_,_/|_,_/|___/_/|_,_/    Jungle Monkey: http://www.junglemonkey.net





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]