summaryrefslogtreecommitdiff
path: root/libnetfs/io-read.c
diff options
context:
space:
mode:
authorMarcus Brinkmann <marcus@gnu.org>2002-05-23 21:24:18 +0000
committerMarcus Brinkmann <marcus@gnu.org>2002-05-23 21:24:18 +0000
commitecc17687614c8502a055166758758942622814c9 (patch)
tree719531bdf07b439044e672b4f23bf562068387a7 /libnetfs/io-read.c
parent03969ed20237d7a2a0b1fdd166fa17727b918ac0 (diff)
2002-05-23 Marcus Brinkmann <marcus@gnu.org>
* io-read.c (netfs_S_io_read): If desired amount is larger than symlink length, truncate amount. Actually use WHOLE_LINK to store link target temporarily. When reading the link target directly, update *DATALEN.
Diffstat (limited to 'libnetfs/io-read.c')
-rw-r--r--libnetfs/io-read.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/libnetfs/io-read.c b/libnetfs/io-read.c
index a4b1b2e2..ff8fbcff 100644
--- a/libnetfs/io-read.c
+++ b/libnetfs/io-read.c
@@ -65,6 +65,8 @@ netfs_S_io_read (struct protid *user,
if (start + amount > size)
amount = size - start;
+ if (amount > size)
+ amount = size;
if (start >= size)
{
@@ -74,7 +76,7 @@ netfs_S_io_read (struct protid *user,
else if (amount < size || start > 0)
{
char *whole_link = alloca (size);
- err = netfs_attempt_readlink (user->user, node, *data);
+ err = netfs_attempt_readlink (user->user, node, whole_link);
if (! err)
{
memcpy (*data, whole_link + start, amount);
@@ -82,7 +84,10 @@ netfs_S_io_read (struct protid *user,
}
}
else
- err = netfs_attempt_readlink (user->user, node, *data);
+ {
+ err = netfs_attempt_readlink (user->user, node, *data);
+ *datalen = amount;
+ }
}
else
/* Read from a normal file. */