diff --git a/vfs/extfs.c b/vfs/extfs.c index 29d324979..94fc451f9 100644 --- a/vfs/extfs.c +++ b/vfs/extfs.c @@ -974,13 +974,13 @@ static int extfs_fstat (void *data, struct stat *buf) } static int -extfs_readlink (struct vfs_class *me, const char *path, char *buf, int size) +extfs_readlink (struct vfs_class *me, const char *path, char *buf, size_t size) { struct archive *archive; char *q; size_t len; struct entry *entry; - char *mpath = g_strdup(path); + char *mpath = g_strdup (path); int result = -1; if ((q = extfs_get_path_mangle (mpath, &archive, 0, 0)) == NULL) @@ -993,8 +993,10 @@ extfs_readlink (struct vfs_class *me, const char *path, char *buf, int size) goto cleanup; } len = strlen (entry->inode->linkname); - result = len > (size - 1) ? size - 1 : len; - g_strlcpy (buf, entry->inode->linkname, result + 1); + if (size < len) + len = size; + /* readlink() does not append a NUL character to buf */ + memcpy (buf, entry->inode->linkname, result = len); cleanup: g_free (mpath); return result; diff --git a/vfs/ftpfs.c b/vfs/ftpfs.c index a255c7aa5..5c815b7cd 100644 --- a/vfs/ftpfs.c +++ b/vfs/ftpfs.c @@ -1669,7 +1669,8 @@ ftpfs_fill_names (struct vfs_class *me, fill_names_f func) } static char buffer[BUF_MEDIUM]; -static char *netrc, *netrcp; +static char *netrc; +static const char *netrcp; /* This should match the keywords[] array below */ typedef enum { diff --git a/vfs/tar.c b/vfs/tar.c index 86d91b4d6..a8b490735 100644 --- a/vfs/tar.c +++ b/vfs/tar.c @@ -410,7 +410,7 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive, char *bp, *data; int size, written; - if (h_size > MC_MAXPATHLEN) { + if (*h_size > MC_MAXPATHLEN) { message (1, MSG_ERROR, _("Inconsistent tar archive")); return STATUS_BADCHECKSUM; } diff --git a/vfs/vfs-impl.h b/vfs/vfs-impl.h index 9ae487680..eb67b3b8e 100644 --- a/vfs/vfs-impl.h +++ b/vfs/vfs-impl.h @@ -46,7 +46,7 @@ struct vfs_class { struct utimbuf * times); int (*readlink) (struct vfs_class *me, const char *path, char *buf, - int size); + size_t size); int (*symlink) (struct vfs_class *me, const char *n1, const char *n2); int (*link) (struct vfs_class *me, const char *p1, const char *p2); int (*unlink) (struct vfs_class *me, const char *path);