Boost logo

Boost :

From: SourceForge.net (noreply_at_[hidden])
Date: 2007-01-31 11:27:00


Patches item #1452698, was opened at 2006-03-17 20:08
Message generated for change (Comment added) made by gmsb
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=307586&aid=1452698&group_id=7586

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Jonathan Turkanis (turkanis)
Summary: iostreams // file_descriptor::seek BUG on files > 4 GB

Initial Comment:

Boost 1.33.1
iostreams library
file_descriptor::seek() method
file_descriptor.cpp, line 198
Win32, Visual C++ 2005

The method seek() can return a wrong value of a newly
set offset when the offset is further than 4 GB.

//---------------
return offset_to_position((lDistanceToMoveHigh << 32)
+ dwResultLow);
//---------------

The code above has a bug. On 32-bit systems the
expression (lDistanceToMoveHigh << 32) equals to
lDistanceToMoveHigh.

The correct code should first cast the
lDistanceToMoveHigh variable to 64-bit and then shift
it.

//---------------
return (static_cast<boost::intmax_t>
lDistanceToMoveHigh) << 32) + dwResultLow;
//---------------

Sergey Kolodkin

----------------------------------------------------------------------

Comment By: Gareth Sylvester-Bradley (gmsb)
Date: 2007-01-31 16:27

Message:
Logged In: YES
user_id=271167
Originator: NO

There's also a bug 3 lines earlier. Windows GetLastError() shouldn't be
checked unless dwResultLow is INVALID_SET_FILE_POINTER.

Replace:

  195 if (::GetLastError() != NO_ERROR) {
  196 throw detail::bad_seek();
  197 } else {
  198 return offset_to_position((lDistanceToMoveHigh << 32) +
dwResultLow);
  199 }
  200 }

With:

  195 if (INVALID_SET_FILE_POINTER == dwResultLow && ::GetLastError() !=
NO_ERROR) {
  196 throw detail::bad_seek();
  197 } else {
  198 return
offset_to_position((static_cast<stream_offset>(lDistanceToMoveHigh) << 32)
+ dwResultLow);
  199 }
  200 }

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=307586&aid=1452698&group_id=7586

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Boost-bugs mailing list
Boost-bugs_at_[hidden]
https://lists.sourceforge.net/lists/listinfo/boost-bugs


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk