summaryrefslogtreecommitdiffstats
path: root/sys/compat
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2001-10-14 03:56:53 +0000
committermarcel <marcel@FreeBSD.org>2001-10-14 03:56:53 +0000
commitf59b6541ee46e925cbb31ca05e4d2d6bc3002415 (patch)
treecbe7b7c162c202ac68af643762010b26e9e2ae1c /sys/compat
parent3b3f4a1ff2cfb3272b82ea8e02d54211ada91690 (diff)
downloadFreeBSD-src-f59b6541ee46e925cbb31ca05e4d2d6bc3002415.zip
FreeBSD-src-f59b6541ee46e925cbb31ca05e4d2d6bc3002415.tar.gz
When casting from uid16/gid16 to uid/gid respectively, make sure
that "no change" (ie 0xFFFF) is properly cast to (int)-1 for those syscalls that set uids and/or gids. Verified by: LTP
Diffstat (limited to 'sys/compat')
-rw-r--r--sys/compat/linux/linux_uid16.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/sys/compat/linux/linux_uid16.c b/sys/compat/linux/linux_uid16.c
index 80e5763..dcb61a7 100644
--- a/sys/compat/linux/linux_uid16.c
+++ b/sys/compat/linux/linux_uid16.c
@@ -42,6 +42,8 @@ DUMMY(setfsgid16);
DUMMY(getresuid16);
DUMMY(getresgid16);
+#define CAST_NOCHG(x) (x == 0xFFFF) ? -1 : x;
+
int
linux_chown16(struct thread *td, struct linux_chown16_args *args)
{
@@ -58,8 +60,8 @@ linux_chown16(struct thread *td, struct linux_chown16_args *args)
#endif
bsd.path = args->path;
- bsd.uid = args->uid;
- bsd.gid = args->gid;
+ bsd.uid = CAST_NOCHG(args->uid);
+ bsd.gid = CAST_NOCHG(args->gid);
return (chown(td, &bsd));
}
@@ -79,8 +81,8 @@ linux_lchown16(struct thread *td, struct linux_lchown16_args *args)
#endif
bsd.path = args->path;
- bsd.uid = args->uid;
- bsd.gid = args->gid;
+ bsd.uid = CAST_NOCHG(args->uid);
+ bsd.gid = CAST_NOCHG(args->gid);
return (lchown(td, &bsd));
}
@@ -249,8 +251,8 @@ linux_setregid16(struct thread *td, struct linux_setregid16_args *args)
{
struct setregid_args bsd;
- bsd.rgid = args->rgid;
- bsd.egid = args->egid;
+ bsd.rgid = CAST_NOCHG(args->rgid);
+ bsd.egid = CAST_NOCHG(args->egid);
return (setregid(td, &bsd));
}
@@ -259,8 +261,8 @@ linux_setreuid16(struct thread *td, struct linux_setreuid16_args *args)
{
struct setreuid_args bsd;
- bsd.ruid = args->ruid;
- bsd.euid = args->euid;
+ bsd.ruid = CAST_NOCHG(args->ruid);
+ bsd.euid = CAST_NOCHG(args->euid);
return (setreuid(td, &bsd));
}
@@ -269,9 +271,9 @@ linux_setresgid16(struct thread *td, struct linux_setresgid16_args *args)
{
struct setresgid_args bsd;
- bsd.rgid = args->rgid;
- bsd.egid = args->egid;
- bsd.sgid = args->sgid;
+ bsd.rgid = CAST_NOCHG(args->rgid);
+ bsd.egid = CAST_NOCHG(args->egid);
+ bsd.sgid = CAST_NOCHG(args->sgid);
return (setresgid(td, &bsd));
}
@@ -280,8 +282,8 @@ linux_setresuid16(struct thread *td, struct linux_setresuid16_args *args)
{
struct setresuid_args bsd;
- bsd.ruid = args->ruid;
- bsd.euid = args->euid;
- bsd.suid = args->suid;
+ bsd.ruid = CAST_NOCHG(args->ruid);
+ bsd.euid = CAST_NOCHG(args->euid);
+ bsd.suid = CAST_NOCHG(args->suid);
return (setresuid(td, &bsd));
}
OpenPOWER on IntegriCloud