* Seek() must always fail when the resulting offset would be smaller than 0

- "correcting" the offset to 0 is not what should happen.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28688 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2008-11-18 21:29:04 +00:00
parent 578dac0cf3
commit c58463ff10
+10 -11
View File
@@ -143,17 +143,14 @@ BBufferIO::Seek(off_t position, uint32 seekMode)
if (fStream == NULL) if (fStream == NULL)
return B_NO_INIT; return B_NO_INIT;
off_t newPosition = fPosition;
switch (seekMode) { switch (seekMode) {
case SEEK_CUR: case SEEK_CUR:
fPosition += position; newPosition += position;
if (fPosition < 0)
fPosition = 0;
break; break;
case SEEK_SET: case SEEK_SET:
if (position < 0) newPosition = position;
return B_BAD_VALUE;
fPosition = position;
break; break;
case SEEK_END: case SEEK_END:
{ {
@@ -162,14 +159,16 @@ BBufferIO::Seek(off_t position, uint32 seekMode)
if (status != B_OK) if (status != B_OK)
return status; return status;
fPosition = size - position; newPosition = size - position;
if (fPosition < 0)
fPosition = 0;
break; break;
} }
} }
return fPosition; if (newPosition < 0)
return B_BAD_VALUE;
fPosition = newPosition;
return newPosition;
} }