summaryrefslogtreecommitdiff
path: root/lib/Buffer.cc
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2009-06-02 00:07:39 +0000
committerPixel <pixel@nobis-crew.org>2009-06-02 00:07:39 +0000
commit7170b90c2ad8c3014c69f12a0192e7464336f492 (patch)
tree8f82d646afc44c84c42c65061633710d3e5003f9 /lib/Buffer.cc
parenteb51dba54cca1085dd023280f0772888a6310aed (diff)
Protecting Buffers against erratic seeks.
Diffstat (limited to 'lib/Buffer.cc')
-rw-r--r--lib/Buffer.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Buffer.cc b/lib/Buffer.cc
index 68ecb9e..473da62 100644
--- a/lib/Buffer.cc
+++ b/lib/Buffer.cc
@@ -181,9 +181,11 @@ bool Buffer::CanSeek() const {
}
off_t Buffer::seek(off_t off, int wheel) throw (GeneralException) {
+ size_t old_ptr;
if (!seekable) {
throw GeneralException("This buffer is a fifo, thus is not seekable");
}
+ old_ptr = ptr;
switch (wheel) {
case SEEK_SET:
ptr = off;
@@ -195,6 +197,10 @@ off_t Buffer::seek(off_t off, int wheel) throw (GeneralException) {
ptr = realsiz + off;
break;
}
+ if (ptr < 0) {
+ ptr = old_ptr;
+ throw GeneralException("Can't seek a Buffer before its start.")
+ }
operator[](ptr);
return ptr;
}