* direntry.c (vfs_s_dump): Commented out.

* extfs.c (s_readlink): Fix return value and possible buffer
overflow.
* mcfs.c (mcfs_readlink): Fix return value.
* mcserv.c (do_readlink):  Fix possible off-by-one.
(commands): Make const array and remove needless comma.
This commit is contained in:
Pavel Roskin 2003-08-29 22:48:25 +00:00
parent 8b3b8147d7
commit 94e14aacfb
5 changed files with 25 additions and 9 deletions

View File

@ -1,3 +1,12 @@
2003-08-29 Andrew V. Samoilov <sav@bcs.zp.ua>
* direntry.c (vfs_s_dump): Commented out.
* extfs.c (s_readlink): Fix return value and possible buffer
overflow.
* mcfs.c (mcfs_readlink): Fix return value.
* mcserv.c (do_readlink): Fix possible off-by-one.
(commands): Make const array and remove needless comma.
2003-08-29 Pavel Roskin <proski@gnu.org>
* ftpfs.c (initconn): Use more portable initialization.

View File

@ -1011,6 +1011,7 @@ vfs_s_ferrno (vfs *me)
return me->verrno;
}
#if 0
void
vfs_s_dump (vfs *me, char *prefix, vfs_s_inode *ino)
{
@ -1030,6 +1031,7 @@ vfs_s_dump (vfs *me, char *prefix, vfs_s_inode *ino)
}
}
}
#endif
char *
vfs_s_getlocalcopy (vfs *me, char *path)

View File

@ -997,7 +997,8 @@ static int s_fstat (void *data, struct stat *buf)
return 0;
}
static int s_readlink (vfs *me, char *path, char *buf, int size)
static int
s_readlink (vfs *me, char *path, char *buf, int size)
{
struct archive *archive;
char *q;
@ -1008,10 +1009,11 @@ static int s_readlink (vfs *me, char *path, char *buf, int size)
return -1;
entry = find_entry (archive->root_entry, q, 0, 0);
if (entry == NULL)
return -1;
if (!S_ISLNK (entry->inode->mode)) ERRNOR (EINVAL, -1);
if (size > (i = strlen (entry->inode->linkname))) {
size = i;
return -1;
if (!S_ISLNK (entry->inode->mode))
ERRNOR (EINVAL, -1);
if (size < (i = strlen (entry->inode->linkname))) {
i = size;
}
strncpy (buf, entry->inode->linkname, i);
return i;

View File

@ -985,9 +985,12 @@ mcfs_readlink (vfs *me, char *path, char *buf, int size)
if (!rpc_get (mc->sock, RPC_STRING, &stat_str, RPC_END))
return the_error (-1, EIO);
status = strlen (stat_str);
if (status < size)
size = status;
strncpy (buf, stat_str, size);
g_free (stat_str);
return strlen (buf);
return size;
}
static int

View File

@ -582,7 +582,7 @@ do_readlink (void)
int n;
rpc_get (msock, RPC_STRING, &file, RPC_END);
n = readlink (file, buffer, 2048);
n = readlink (file, buffer, 2048 - 1);
send_status (n, errno);
if (n >= 0) {
buffer[n] = 0;
@ -1080,7 +1080,7 @@ do_login (void)
/* This structure must be kept in synch with mcfs.h enums */
static struct _command {
static const struct _command {
char *command;
void (*callback) (void);
} commands[] = {
@ -1111,7 +1111,7 @@ static struct _command {
"getupdir", do_getupdir}, {
"login", do_login}, {
"quit", do_quit}, {
"utime", do_utime},};
"utime", do_utime}};
static int ncommands = sizeof (commands) / sizeof (struct _command);