1
1

* 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.
Этот коммит содержится в:
Andrew V. Samoilov 2004-09-02 13:57:59 +00:00
родитель c44a4a4c31
Коммит e04694309c
4 изменённых файлов: 10 добавлений и 7 удалений

Просмотреть файл

@ -974,13 +974,13 @@ static int extfs_fstat (void *data, struct stat *buf)
} }
static int 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; struct archive *archive;
char *q; char *q;
size_t len; size_t len;
struct entry *entry; struct entry *entry;
char *mpath = g_strdup(path); char *mpath = g_strdup (path);
int result = -1; int result = -1;
if ((q = extfs_get_path_mangle (mpath, &archive, 0, 0)) == NULL) 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; goto cleanup;
} }
len = strlen (entry->inode->linkname); len = strlen (entry->inode->linkname);
result = len > (size - 1) ? size - 1 : len; if (size < len)
g_strlcpy (buf, entry->inode->linkname, result + 1); len = size;
/* readlink() does not append a NUL character to buf */
memcpy (buf, entry->inode->linkname, result = len);
cleanup: cleanup:
g_free (mpath); g_free (mpath);
return result; return result;

Просмотреть файл

@ -1669,7 +1669,8 @@ ftpfs_fill_names (struct vfs_class *me, fill_names_f func)
} }
static char buffer[BUF_MEDIUM]; static char buffer[BUF_MEDIUM];
static char *netrc, *netrcp; static char *netrc;
static const char *netrcp;
/* This should match the keywords[] array below */ /* This should match the keywords[] array below */
typedef enum { typedef enum {

Просмотреть файл

@ -410,7 +410,7 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive,
char *bp, *data; char *bp, *data;
int size, written; int size, written;
if (h_size > MC_MAXPATHLEN) { if (*h_size > MC_MAXPATHLEN) {
message (1, MSG_ERROR, _("Inconsistent tar archive")); message (1, MSG_ERROR, _("Inconsistent tar archive"));
return STATUS_BADCHECKSUM; return STATUS_BADCHECKSUM;
} }

Просмотреть файл

@ -46,7 +46,7 @@ struct vfs_class {
struct utimbuf * times); struct utimbuf * times);
int (*readlink) (struct vfs_class *me, const char *path, char *buf, 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 (*symlink) (struct vfs_class *me, const char *n1, const char *n2);
int (*link) (struct vfs_class *me, const char *p1, const char *p2); int (*link) (struct vfs_class *me, const char *p1, const char *p2);
int (*unlink) (struct vfs_class *me, const char *path); int (*unlink) (struct vfs_class *me, const char *path);