Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/powerpc/booke Let copyinstr(9) return ENAMETOOLONG ...
details: https://anonhg.NetBSD.org/src/rev/0219f31ccc8c
branches: trunk
changeset: 969807:0219f31ccc8c
user: rin <rin%NetBSD.org@localhost>
date: Mon Mar 02 03:34:28 2020 +0000
description:
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 b9187311ca5d -r 0219f31ccc8c sys/arch/powerpc/booke/copyin.c
--- a/sys/arch/powerpc/booke/copyin.c Mon Mar 02 01:46:02 2020 +0000
+++ b/sys/arch/powerpc/booke/copyin.c Mon Mar 02 03:34:28 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.8 2020/03/02 03:34:28 rin 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.8 2020/03/02 03:34:28 rin 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