Ticket #3145: fseek-fix.diff

File fseek-fix.diff, 1.7 KB (added by hamish, 13 years ago)

Fixes ungetc/fseek bug as described in #3145

  • src/system/libroot/posix/glibc/libio/fileops.c

     
    10281028    {
    10291029      /* Offset relative to start of main get area. */
    10301030      _IO_off64_t rel_offset = (offset - fp->_offset
    1031                 + (fp->_IO_read_end - fp->_IO_read_base));
     1031                + (fp->_IO_read_end - fp->_IO_buf_base));
    10321032      if (rel_offset >= 0)
    10331033    {
    10341034#if 0
    10351035      if (_IO_in_backup (fp))
    10361036        _IO_switch_to_main_get_area (fp);
    10371037#endif
    1038       if (rel_offset <= fp->_IO_read_end - fp->_IO_read_base)
     1038      if (rel_offset <= fp->_IO_read_end - fp->_IO_buf_base)
    10391039        {
    10401040          _IO_setg (fp, fp->_IO_buf_base, fp->_IO_buf_base + rel_offset,
    10411041            fp->_IO_read_end);
  • src/system/libroot/posix/glibc/libio/wfileops.c

     
    638638    {
    639639      /* Offset relative to start of main get area. */
    640640      _IO_off64_t rel_offset = (offset - fp->_offset
    641                 + (fp->_IO_read_end - fp->_IO_read_base));
     641                + (fp->_IO_read_end - fp->_IO_buf_base));
    642642      if (rel_offset >= 0)
    643643    {
    644644#if 0
    645645      if (_IO_in_backup (fp))
    646646        _IO_switch_to_main_get_area (fp);
    647647#endif
    648       if (rel_offset <= fp->_IO_read_end - fp->_IO_read_base)
     648      if (rel_offset <= fp->_IO_read_end - fp->_IO_buf_base)
    649649        {
    650650          enum __codecvt_result status;
    651651          struct _IO_codecvt *cd = fp->_codecvt;