diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2003-05-11 03:26:04 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2003-05-11 03:26:04 +0000 |
commit | bf10b4778e396bbcf744c814de7520506bd35f00 (patch) | |
tree | 15b0e5103c54d9c720a609bc68bd1cedded72a4d /sys/arch | |
parent | a57beaa3b4c2234d868dc8d7c988b467ed7b4f2d (diff) |
check done for NULL before dereferencing. ok drahn@
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/powerpc/powerpc/copystr.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/sys/arch/powerpc/powerpc/copystr.c b/sys/arch/powerpc/powerpc/copystr.c index a38c844e0b6..479b136dd40 100644 --- a/sys/arch/powerpc/powerpc/copystr.c +++ b/sys/arch/powerpc/powerpc/copystr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: copystr.c,v 1.6 2002/09/15 09:01:59 deraadt Exp $ */ +/* $OpenBSD: copystr.c,v 1.7 2003/05/11 03:26:03 tedu Exp $ */ /*- * Copyright (C) 1995 Wolfgang Solfrank. @@ -38,11 +38,7 @@ * Emulate copyinstr. */ int -copystr(kfaddr, kdaddr, len, done) - const void *kfaddr; - void *kdaddr; - size_t len; - size_t *done; +copystr(const void *kfaddr, void *kdaddr, size_t len, size_t *done) { u_char *kfp = (u_char *)kfaddr; u_char *kdp = kdaddr; @@ -50,10 +46,12 @@ copystr(kfaddr, kdaddr, len, done) for (l = 0; len-- > 0; l++) { if (!(*kdp++ = *kfp++)) { - *done = l + 1; - return 0; + if (done) + *done = l + 1; + return (0); } } - *done = l; - return ENAMETOOLONG; + if (done) + *done = l; + return (ENAMETOOLONG); } |