Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern The userland namelen is size_t, but the kernel hold...



details:   https://anonhg.NetBSD.org/src/rev/e33d8d9f4ace
branches:  trunk
changeset: 803272:e33d8d9f4ace
user:      maxv <maxv%NetBSD.org@localhost>
date:      Mon Oct 20 08:20:08 2014 +0000

description:
The userland namelen is size_t, but the kernel holds it in an int. The
sizeof(login) test implicitly interprets 'namelen' as unsigned, which
means that negative values get kicked anyway. Still this is fragile, so:
        int -> size_t

diffstat:

 sys/kern/kern_prot.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r 1b8d64cc4ac3 -r e33d8d9f4ace sys/kern/kern_prot.c
--- a/sys/kern/kern_prot.c      Mon Oct 20 07:13:27 2014 +0000
+++ b/sys/kern/kern_prot.c      Mon Oct 20 08:20:08 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_prot.c,v 1.117 2013/11/25 16:28:20 rmind Exp $    */
+/*     $NetBSD: kern_prot.c,v 1.118 2014/10/20 08:20:08 maxv Exp $     */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1990, 1991, 1993
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_prot.c,v 1.117 2013/11/25 16:28:20 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_prot.c,v 1.118 2014/10/20 08:20:08 maxv Exp $");
 
 #include "opt_compat_43.h"
 
@@ -590,7 +590,7 @@
        } */
        struct proc *p = l->l_proc;
        char login[sizeof(p->p_session->s_login)];
-       int namelen = SCARG(uap, namelen);
+       size_t namelen = SCARG(uap, namelen);
 
        if (namelen > sizeof(login))
                namelen = sizeof(login);



Home | Main Index | Thread Index | Old Index