summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>1999-08-29 08:52:38 +0000
committermarcel <marcel@FreeBSD.org>1999-08-29 08:52:38 +0000
commita932c8483a31262b22f6f0ccc03e264207884b41 (patch)
treeeea72d62e740d9fd619b91beb5cfa52f2fdadd39 /sys
parent62f99fc1fd038d1b40b3c17fe01bf069ce0d9a3c (diff)
downloadFreeBSD-src-a932c8483a31262b22f6f0ccc03e264207884b41.zip
FreeBSD-src-a932c8483a31262b22f6f0ccc03e264207884b41.tar.gz
Fix a missing '-1' in the size argument of copyout in getgroups. Spotted while
reviewing the MFC in -stable.
Diffstat (limited to 'sys')
-rw-r--r--sys/compat/linux/linux_misc.c12
-rw-r--r--sys/i386/linux/linux_misc.c12
2 files changed, 12 insertions, 12 deletions
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c
index 9834875..323ecdb 100644
--- a/sys/compat/linux/linux_misc.c
+++ b/sys/compat/linux/linux_misc.c
@@ -1204,7 +1204,7 @@ linux_getgroups(p, uap)
pc = p->p_cred;
bsd_gidset = pc->pc_ucred->cr_groups;
- bsd_gidsetsz = pc->pc_ucred->cr_ngroups;
+ bsd_gidsetsz = pc->pc_ucred->cr_ngroups - 1;
/*
* cr_groups[0] holds egid. Returning the whole set
@@ -1213,16 +1213,16 @@ linux_getgroups(p, uap)
*/
if ((ngrp = uap->gidsetsize) == 0) {
- p->p_retval[0] = bsd_gidsetsz - 1;
+ p->p_retval[0] = bsd_gidsetsz;
return (0);
}
- if (ngrp < bsd_gidsetsz - 1)
+ if (ngrp < bsd_gidsetsz)
return (EINVAL);
- ngrp = 1;
+ ngrp = 0;
while (ngrp < bsd_gidsetsz) {
- linux_gidset[ngrp - 1] = bsd_gidset[ngrp];
+ linux_gidset[ngrp] = bsd_gidset[ngrp + 1];
ngrp++;
}
@@ -1230,7 +1230,7 @@ linux_getgroups(p, uap)
ngrp * sizeof(linux_gid_t))))
return (error);
- p->p_retval[0] = ngrp - 1;
+ p->p_retval[0] = ngrp;
return (0);
}
diff --git a/sys/i386/linux/linux_misc.c b/sys/i386/linux/linux_misc.c
index 9834875..323ecdb 100644
--- a/sys/i386/linux/linux_misc.c
+++ b/sys/i386/linux/linux_misc.c
@@ -1204,7 +1204,7 @@ linux_getgroups(p, uap)
pc = p->p_cred;
bsd_gidset = pc->pc_ucred->cr_groups;
- bsd_gidsetsz = pc->pc_ucred->cr_ngroups;
+ bsd_gidsetsz = pc->pc_ucred->cr_ngroups - 1;
/*
* cr_groups[0] holds egid. Returning the whole set
@@ -1213,16 +1213,16 @@ linux_getgroups(p, uap)
*/
if ((ngrp = uap->gidsetsize) == 0) {
- p->p_retval[0] = bsd_gidsetsz - 1;
+ p->p_retval[0] = bsd_gidsetsz;
return (0);
}
- if (ngrp < bsd_gidsetsz - 1)
+ if (ngrp < bsd_gidsetsz)
return (EINVAL);
- ngrp = 1;
+ ngrp = 0;
while (ngrp < bsd_gidsetsz) {
- linux_gidset[ngrp - 1] = bsd_gidset[ngrp];
+ linux_gidset[ngrp] = bsd_gidset[ngrp + 1];
ngrp++;
}
@@ -1230,7 +1230,7 @@ linux_getgroups(p, uap)
ngrp * sizeof(linux_gid_t))))
return (error);
- p->p_retval[0] = ngrp - 1;
+ p->p_retval[0] = ngrp;
return (0);
}
OpenPOWER on IntegriCloud