summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Schwinge <tschwinge@gnu.org>2006-06-15 13:52:31 +0000
committerThomas Schwinge <tschwinge@gnu.org>2006-06-15 13:52:31 +0000
commita55e2129494c2559df9fb6534356a423c6de728c (patch)
tree01a3215d48ee40e57972409b8d336c9e47b7b33b
parent218307d36556c9e9a5cdbfc987419e16d56d352d (diff)
2006-06-15 Thomas Schwinge <tschwinge@gnu.org>
* hello-mt.c (trivfs_S_io_seek): Seek into the right direction for `SEEK_END'. Return EINVAL if file pointer would become negative. * hello.c (trivfs_S_io_seek): Likewise.
-rw-r--r--trans/ChangeLog6
-rw-r--r--trans/hello-mt.c19
-rw-r--r--trans/hello.c19
3 files changed, 28 insertions, 16 deletions
diff --git a/trans/ChangeLog b/trans/ChangeLog
index 47de6762..e8636aa5 100644
--- a/trans/ChangeLog
+++ b/trans/ChangeLog
@@ -1,3 +1,9 @@
+2006-06-15 Thomas Schwinge <tschwinge@gnu.org>
+
+ * hello-mt.c (trivfs_S_io_seek): Seek into the right direction for
+ `SEEK_END'. Return EINVAL if file pointer would become negative.
+ * hello.c (trivfs_S_io_seek): Likewise.
+
2006-03-25 Thomas Schwinge <tschwinge@gnu.org>
[bug #15808]
diff --git a/trans/hello-mt.c b/trans/hello-mt.c
index cc338f92..b933cfde 100644
--- a/trans/hello-mt.c
+++ b/trans/hello-mt.c
@@ -1,5 +1,5 @@
/* hello-mt.c - A trivial single-file translator, multithreaded version
- Copyright (C) 1998,99,2001,02 Free Software Foundation, Inc.
+ Copyright (C) 1998,99,2001,02,2006 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -195,19 +195,22 @@ trivfs_S_io_seek (struct trivfs_protid *cred,
switch (whence)
{
- case SEEK_SET:
- op->offs = offs; break;
case SEEK_CUR:
- op->offs += offs; break;
+ offs += op->offs;
+ goto check;
case SEEK_END:
- op->offs = contents_len - offs; break;
+ offs += contents_len;
+ case SEEK_SET:
+ check:
+ if (offs >= 0)
+ {
+ *new_offs = op->offs = offs;
+ break;
+ }
default:
err = EINVAL;
}
- if (! err)
- *new_offs = op->offs;
-
mutex_unlock (&op->lock);
return err;
diff --git a/trans/hello.c b/trans/hello.c
index d36ba848..c49feeb2 100644
--- a/trans/hello.c
+++ b/trans/hello.c
@@ -1,5 +1,5 @@
/* hello.c - A trivial single-file translator
- Copyright (C) 1998, 1999,2001,02 Free Software Foundation, Inc.
+ Copyright (C) 1998,1999,2001,02,2006 Free Software Foundation, Inc.
Gordon Matzigkeit <gord@fig.org>, 1999
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -171,19 +171,22 @@ trivfs_S_io_seek (struct trivfs_protid *cred,
op = cred->po->hook;
switch (whence)
{
- case SEEK_SET:
- op->offs = offs; break;
case SEEK_CUR:
- op->offs += offs; break;
+ offs += op->offs;
+ goto check;
case SEEK_END:
- op->offs = contents_len - offs; break;
+ offs += contents_len;
+ case SEEK_SET:
+ check:
+ if (offs >= 0)
+ {
+ *new_offs = op->offs = offs;
+ break;
+ }
default:
err = EINVAL;
}
- if (! err)
- *new_offs = op->offs;
-
return err;
}