From 95b1426fb75a5458ac15d28a04501327875fa58d Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Thu, 15 Jun 2006 13:54:08 +0000 Subject: 2006-06-15 Thomas Schwinge * open.c (open_seek): Seek into the correct direction for `SEEK_END'. Return EINVAL if file pointer would become negative. --- storeio/ChangeLog | 5 +++++ storeio/open.c | 19 +++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) (limited to 'storeio') diff --git a/storeio/ChangeLog b/storeio/ChangeLog index 75374a1e..e14aaed4 100644 --- a/storeio/ChangeLog +++ b/storeio/ChangeLog @@ -1,3 +1,8 @@ +2006-06-15 Thomas Schwinge + + * open.c (open_seek): Seek into the correct direction for `SEEK_END'. + Return EINVAL if file pointer would become negative. + 2005-01-08 Marco Gerards * storeio.c (trivfs_modify_stat): Don't initialize st_blocks. diff --git a/storeio/open.c b/storeio/open.c index b1013a94..805115ce 100644 --- a/storeio/open.c +++ b/storeio/open.c @@ -1,6 +1,6 @@ /* Per-open information for storeio - Copyright (C) 1995, 1996 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 2006 Free Software Foundation, Inc. Written by Miles Bader @@ -105,19 +105,22 @@ open_seek (struct open *open, off_t offs, int whence, off_t *new_offs) switch (whence) { - case SEEK_SET: - open->offs = offs; break; case SEEK_CUR: - open->offs += offs; break; + offs += open->offs; + goto check; case SEEK_END: - open->offs = open->dev->store->size - offs; break; + offs += open->dev->store->size; + case SEEK_SET: + check: + if (offs >= 0) + { + *new_offs = open->offs = offs; + break; + } default: err = EINVAL; } - if (! err) - *new_offs = open->offs; - mutex_unlock (&open->lock); return err; -- cgit v1.2.3