From fc3bf048e9cd469588fb281e65fa5e16b9b7aae2 Mon Sep 17 00:00:00 2001 From: "Andrew V. Samoilov" Date: Thu, 2 Sep 2004 14:12:21 +0000 Subject: [PATCH] * local.c (local_readlink): Make "size" size_t. * direntry.c (vfs_s_readlink): Revert last changes. Make "size" size_t. * sfs.c (sfs_readlink): Reformat function. * smbfs.c (smbfs_readlink): Reformat function. --- vfs/ChangeLog | 14 ++++++++++++++ vfs/direntry.c | 11 ++++++++--- vfs/local.c | 2 +- vfs/sfs.c | 3 ++- vfs/smbfs.c | 8 +++++--- 5 files changed, 30 insertions(+), 8 deletions(-) diff --git a/vfs/ChangeLog b/vfs/ChangeLog index 16bc9e644..1c0b40662 100644 --- a/vfs/ChangeLog +++ b/vfs/ChangeLog @@ -1,3 +1,17 @@ +2004-09-02 Andrew V. Samoilov + + * tar.c (tar_read_header): Fix missed *. + * extfs.c (extfs_readlink): Revert last change: readlink does not + append a NUL character to buf. + * ftpfs.c: Warning fix. + * vfs-impl.h (struct vfs_class.readlink): Make "size" size_t. + Adjust all callers. + * local.c (local_readlink): Make "size" size_t. + * direntry.c (vfs_s_readlink): Revert last changes. Make "size" + size_t. + * sfs.c (sfs_readlink): Reformat function. + * smbfs.c (smbfs_readlink): Reformat function. + 2004-09-02 Roland Illig * mcfs.c (mcfs_readlink): Fixed syntax error (usage of diff --git a/vfs/direntry.c b/vfs/direntry.c index 00549cbf8..d10315c88 100644 --- a/vfs/direntry.c +++ b/vfs/direntry.c @@ -672,9 +672,10 @@ vfs_s_fstat (void *fh, struct stat *buf) } static int -vfs_s_readlink (struct vfs_class *me, const char *path, char *buf, int size) +vfs_s_readlink (struct vfs_class *me, const char *path, char *buf, size_t size) { struct vfs_s_inode *ino; + size_t len; ino = vfs_s_inode_from_path (me, path, 0); if (!ino) @@ -686,8 +687,12 @@ vfs_s_readlink (struct vfs_class *me, const char *path, char *buf, int size) if (ino->linkname == NULL) ERRNOR (EFAULT, -1); - g_strlcpy (buf, ino->linkname, size); - return strlen (buf); + len = strlen (buf); + if (size < len) + len = size; + /* readlink() does not append a NUL character to buf */ + memcpy (buf, ino->linkname, len); + return len; } static void * diff --git a/vfs/local.c b/vfs/local.c index d38f3560a..2d976b632 100644 --- a/vfs/local.c +++ b/vfs/local.c @@ -147,7 +147,7 @@ local_utime (struct vfs_class *me, const char *path, struct utimbuf *times) } static int -local_readlink (struct vfs_class *me, const char *path, char *buf, int size) +local_readlink (struct vfs_class *me, const char *path, char *buf, size_t size) { return readlink (path, buf, size); } diff --git a/vfs/sfs.c b/vfs/sfs.c index e4151092e..ec18f3b16 100644 --- a/vfs/sfs.c +++ b/vfs/sfs.c @@ -235,7 +235,8 @@ static int sfs_utime (struct vfs_class *me, const char *path, struct utimbuf *ti return utime (path, times); } -static int sfs_readlink (struct vfs_class *me, const char *path, char *buf, int size) +static int +sfs_readlink (struct vfs_class *me, const char *path, char *buf, size_t size) { path = sfs_redirect (me, path); return readlink (path, buf, size); diff --git a/vfs/smbfs.c b/vfs/smbfs.c index 2eea575bf..a46d93a39 100644 --- a/vfs/smbfs.c +++ b/vfs/smbfs.c @@ -856,11 +856,13 @@ smbfs_utime (struct vfs_class *me, const char *path, struct utimbuf *times) } static int -smbfs_readlink (struct vfs_class *me, const char *path, char *buf, int size) +smbfs_readlink (struct vfs_class *me, const char *path, char *buf, size_t size) { - DEBUG(3, ("smbfs_readlink(path:%s, buf:%s, size:%d)\n", path, buf, size)); + DEBUG (3, + ("smbfs_readlink(path:%s, buf:%s, size:%d)\n", path, buf, + (int) size)); my_errno = EOPNOTSUPP; - return -1; /* no symlinks on smb filesystem? */ + return -1; /* no symlinks on smb filesystem? */ } static int