fix copy{in,out}str to return ENAMETOOLONG if the string is longer than len bytes.
This commit is contained in:
parent
24dff64cf5
commit
67c6b43e9e
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: copyinout.S,v 1.6 2018/07/24 20:55:49 ryo Exp $ */
|
||||
/* $NetBSD: copyinout.S,v 1.7 2018/07/30 09:08:41 ryo Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2014 The NetBSD Foundation, Inc.
|
||||
@ -29,10 +29,11 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/errno.h>
|
||||
#include <aarch64/asm.h>
|
||||
#include "assym.h"
|
||||
|
||||
RCSID("$NetBSD: copyinout.S,v 1.6 2018/07/24 20:55:49 ryo Exp $");
|
||||
RCSID("$NetBSD: copyinout.S,v 1.7 2018/07/30 09:08:41 ryo Exp $");
|
||||
|
||||
.macro enter_cpu_onfault
|
||||
stp fp, lr, [sp, #-16]! /* save fp, lr */
|
||||
@ -260,6 +261,8 @@ END(copyout)
|
||||
ENTRY(copyinstr)
|
||||
enter_cpu_onfault
|
||||
|
||||
mov x8, #0 /* error = 0 */
|
||||
|
||||
mov x4, xzr /* i = 0 */
|
||||
cbz x2, copyinstr_done /* if (len == 0) goto done */
|
||||
copyinstr_loop:
|
||||
@ -271,14 +274,12 @@ copyinstr_loop:
|
||||
|
||||
cmp x4, x2 /* if (i < len) goto loop */
|
||||
bcc copyinstr_loop
|
||||
mov x8, #ENAMETOOLONG /* error = ENAMETOOLONG */
|
||||
|
||||
copyinstr_done:
|
||||
cbz x3, 1f /* if (done != NULL) *done = i */
|
||||
str x4, [x3]
|
||||
1:
|
||||
|
||||
mov x8, #0 /* return 0 */
|
||||
|
||||
exit_cpu_onfault
|
||||
ret
|
||||
END(copyinstr)
|
||||
@ -289,6 +290,8 @@ END(copyinstr)
|
||||
ENTRY(copyoutstr)
|
||||
enter_cpu_onfault
|
||||
|
||||
mov x8, #0 /* error = 0 */
|
||||
|
||||
mov x4, xzr /* i = 0 */
|
||||
cbz x2, copyoutstr_done /* if (len == 0) goto done */
|
||||
copyoutstr_loop:
|
||||
@ -300,14 +303,12 @@ copyoutstr_loop:
|
||||
|
||||
cmp x4, x2 /* if (i < len) goto loop */
|
||||
bcc copyoutstr_loop
|
||||
mov x8, #ENAMETOOLONG /* error = ENAMETOOLONG */
|
||||
|
||||
copyoutstr_done:
|
||||
cbz x3, 1f /* if (done != NULL) *done = i */
|
||||
str x4, [x3]
|
||||
1:
|
||||
|
||||
mov x8, #0 /* return 0 */
|
||||
|
||||
exit_cpu_onfault
|
||||
ret
|
||||
END(copyoutstr)
|
||||
|
Loading…
Reference in New Issue
Block a user