Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/powerpc/powerpc handle a NULL "done" pointer.



details:   https://anonhg.NetBSD.org/src/rev/1aedfbe45cd1
branches:  trunk
changeset: 482704:1aedfbe45cd1
user:      chs <chs%NetBSD.org@localhost>
date:      Sat Feb 19 23:29:16 2000 +0000

description:
handle a NULL "done" pointer.
for the userspace versions, return EFAULT instead of EACCES
when the user address is bogus.

diffstat:

 sys/arch/powerpc/powerpc/copyinstr.c  |  24 ++++++++++++++----------
 sys/arch/powerpc/powerpc/copyoutstr.c |  23 ++++++++++++++---------
 sys/arch/powerpc/powerpc/copystr.c    |  15 ++++++++++-----
 3 files changed, 38 insertions(+), 24 deletions(-)

diffs (117 lines):

diff -r a119b2e7ffde -r 1aedfbe45cd1 sys/arch/powerpc/powerpc/copyinstr.c
--- a/sys/arch/powerpc/powerpc/copyinstr.c      Sat Feb 19 23:02:17 2000 +0000
+++ b/sys/arch/powerpc/powerpc/copyinstr.c      Sat Feb 19 23:29:16 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: copyinstr.c,v 1.2 1999/01/10 10:24:16 tsubai Exp $     */
+/*     $NetBSD: copyinstr.c,v 1.3 2000/02/19 23:29:16 chs Exp $        */
 
 /*-
  * Copyright (C) 1995 Wolfgang Solfrank.
@@ -44,21 +44,25 @@
        size_t len;
        size_t *done;
 {
-       int c;
        const u_char *up = udaddr;
        u_char *kp = kaddr;
-       int l;
-       
+       size_t l;
+       int c, rv;
+
+       rv = ENAMETOOLONG;
        for (l = 0; len-- > 0; l++) {
                if ((c = fubyte(up++)) < 0) {
-                       *done = l;
-                       return EACCES;
+                       rv = EFAULT;
+                       break;
                }
                if (!(*kp++ = c)) {
-                       *done = l + 1;
-                       return 0;
+                       l++;
+                       rv = 0;
+                       break;
                }
        }
-       *done = l;
-       return ENAMETOOLONG;
+       if (done != NULL) {
+               *done = l;
+       }
+       return rv;
 }
diff -r a119b2e7ffde -r 1aedfbe45cd1 sys/arch/powerpc/powerpc/copyoutstr.c
--- a/sys/arch/powerpc/powerpc/copyoutstr.c     Sat Feb 19 23:02:17 2000 +0000
+++ b/sys/arch/powerpc/powerpc/copyoutstr.c     Sat Feb 19 23:29:16 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: copyoutstr.c,v 1.2 1999/01/10 10:24:16 tsubai Exp $    */
+/*     $NetBSD: copyoutstr.c,v 1.3 2000/02/19 23:29:17 chs Exp $       */
 
 /*-
  * Copyright (C) 1995 Wolfgang Solfrank.
@@ -46,18 +46,23 @@
 {
        const u_char *kp = kaddr;
        u_char *up = udaddr;
-       int l;
-       
+       size_t l;
+       int rv;
+
+       rv = ENAMETOOLONG;
        for (l = 0; len-- > 0; l++) {
                if (subyte(up++, *kp) < 0) {
-                       *done = l;
-                       return EACCES;
+                       rv = EFAULT;
+                       break;
                }
                if (!*kp++) {
-                       *done = l + 1;
-                       return 0;
+                       l++;
+                       rv = 0;
+                       break;
                }
        }
-       *done = l;
-       return ENAMETOOLONG;
+       if (done != NULL) {
+               *done = l;
+       }
+       return rv;
 }
diff -r a119b2e7ffde -r 1aedfbe45cd1 sys/arch/powerpc/powerpc/copystr.c
--- a/sys/arch/powerpc/powerpc/copystr.c        Sat Feb 19 23:02:17 2000 +0000
+++ b/sys/arch/powerpc/powerpc/copystr.c        Sat Feb 19 23:29:16 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: copystr.c,v 1.1 1996/09/30 16:34:43 ws Exp $   */
+/*     $NetBSD: copystr.c,v 1.2 2000/02/19 23:29:17 chs Exp $  */
 
 /*-
  * Copyright (C) 1995 Wolfgang Solfrank.
@@ -46,13 +46,18 @@
        u_char *kfp = kfaddr;
        u_char *kdp = kdaddr;
        size_t l;
+       int rv;
        
+       rv = ENAMETOOLONG;
        for (l = 0; len-- > 0; l++) {
                if (!(*kdp++ = *kfp++)) {
-                       *done = l + 1;
-                       return 0;
+                       l++;
+                       rv = 0;
+                       break;
                }
        }
-       *done = l;
-       return ENAMETOOLONG;
+       if (done != NULL) {
+               *done = l;
+       }
+       return rv;
 }



Home | Main Index | Thread Index | Old Index