Source-Changes-HG archive

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

[src/netbsd-9]: src/sys/arch/powerpc/booke Pull up following revision(s) (req...



details:   https://anonhg.NetBSD.org/src/rev/a8c512284853
branches:  netbsd-9
changeset: 963672:a8c512284853
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Mar 02 08:00:55 2020 +0000

description:
Pull up following revision(s) (requested by rin in ticket #752):

        sys/arch/powerpc/booke/copyin.c: revision 1.8

Let copyinstr(9) return ENAMETOOLONG correctly if source is not
NUL-terminated; it cannot be determined by (uint8_t)data == '\0'
since data is right shifted at the end of loop.

Found by POOL_REDZONE.

diffstat:

 sys/arch/powerpc/booke/copyin.c |  16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diffs (55 lines):

diff -r 0f97fa22acc2 -r a8c512284853 sys/arch/powerpc/booke/copyin.c
--- a/sys/arch/powerpc/booke/copyin.c   Mon Mar 02 07:58:57 2020 +0000
+++ b/sys/arch/powerpc/booke/copyin.c   Mon Mar 02 08:00:55 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: copyin.c,v 1.7 2019/04/07 05:25:55 thorpej Exp $       */
+/*     $NetBSD: copyin.c,v 1.7.4.1 2020/03/02 08:00:55 martin Exp $    */
 
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: copyin.c,v 1.7 2019/04/07 05:25:55 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: copyin.c,v 1.7.4.1 2020/03/02 08:00:55 martin Exp $");
 
 #define        __UFETCHSTORE_PRIVATE
 
@@ -306,6 +306,7 @@
 {
        struct pcb * const pcb = lwp_getpcb(curlwp);
        struct faultbuf env;
+       int rv;
 
        if (__predict_false(len == 0)) {
                if (done)
@@ -313,7 +314,7 @@
                return 0;
        }
 
-       int rv = setfault(&env);
+       rv = setfault(&env);
        if (rv != 0) {
                pcb->pcb_onfault = NULL;
                if (done)
@@ -346,15 +347,14 @@
                *kdaddr8++ = data;
                if ((uint8_t) data == 0) {
                        copylen++;
-                       break;
+                       goto out;
                }
        }
+       rv = ENAMETOOLONG;
 
+out:
        pcb->pcb_onfault = NULL;
        if (done)
                *done = copylen;
-       /*
-        * If the last byte is not NUL (0), then the name is too long.
-        */
-       return (uint8_t)data ? ENAMETOOLONG : 0;
+       return rv;
 }



Home | Main Index | Thread Index | Old Index