1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-18 10:35:55 +00:00

Modify kern___getcwd() to take max pathlen limit as an additional

argument.  This will be used for the Linux emulation layer - for Linux,
PATH_MAX is 4096 and not 1024.

Differential Revision:	https://reviews.freebsd.org/D2335
Reviewed by:	kib@
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Edward Tomasz Napierala 2015-04-21 13:55:24 +00:00
parent 0afebee290
commit 6289b482ec
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=281829
4 changed files with 13 additions and 8 deletions

View File

@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$");
#include <machine/../linux/linux.h>
#include <machine/../linux/linux_proto.h>
#endif
#include <compat/linux/linux_misc.h>
#include <compat/linux/linux_util.h>
#include <security/mac/mac_framework.h>
@ -423,14 +424,14 @@ linux_getcwd(struct thread *td, struct linux_getcwd_args *args)
len = args->bufsize;
if (len > MAXPATHLEN*4)
len = MAXPATHLEN*4;
if (len > LINUX_PATH_MAX)
len = LINUX_PATH_MAX;
else if (len < 2)
return ERANGE;
path = malloc(len, M_TEMP, M_WAITOK);
error = kern___getcwd(td, path, UIO_SYSSPACE, len);
error = kern___getcwd(td, path, UIO_SYSSPACE, len, LINUX_PATH_MAX);
if (!error) {
lenused = strlen(path) + 1;
if (lenused <= args->bufsize) {

View File

@ -55,6 +55,8 @@
#define LINUX_MREMAP_MAYMOVE 1
#define LINUX_MREMAP_FIXED 2
#define LINUX_PATH_MAX 4096
extern const char *linux_platform;
/*

View File

@ -1053,11 +1053,13 @@ sys___getcwd(td, uap)
struct __getcwd_args *uap;
{
return (kern___getcwd(td, uap->buf, UIO_USERSPACE, uap->buflen));
return (kern___getcwd(td, uap->buf, UIO_USERSPACE, uap->buflen,
MAXPATHLEN));
}
int
kern___getcwd(struct thread *td, char *buf, enum uio_seg bufseg, u_int buflen)
kern___getcwd(struct thread *td, char *buf, enum uio_seg bufseg, u_int buflen,
u_int path_max)
{
char *bp, *tmpbuf;
struct filedesc *fdp;
@ -1068,8 +1070,8 @@ kern___getcwd(struct thread *td, char *buf, enum uio_seg bufseg, u_int buflen)
return (ENODEV);
if (buflen < 2)
return (EINVAL);
if (buflen > MAXPATHLEN)
buflen = MAXPATHLEN;
if (buflen > path_max)
buflen = path_max;
tmpbuf = malloc(buflen, M_TEMP, M_WAITOK);
fdp = td->td_proc->p_fd;

View File

@ -58,7 +58,7 @@ struct thr_param;
struct __wrusage;
int kern___getcwd(struct thread *td, char *buf, enum uio_seg bufseg,
u_int buflen);
u_int buflen, u_int path_max);
int kern_accept(struct thread *td, int s, struct sockaddr **name,
socklen_t *namelen, struct file **fp);
int kern_accept4(struct thread *td, int s, struct sockaddr **name,