*
*/
+#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/ioctl.h>
#include <sys/kauth.h>
#include <sys/ucred.h>
#include <sys/proc_internal.h>
+#include <sys/sysproto.h>
#include <sys/user.h>
#include <kern/task.h>
#include <kern/thread.h>
#include <vm/vm_map.h>
+
/*
* copy a null terminated string from the kernel address space into the user
* address space. - if the user is denied write access, return EFAULT. - if
{
size_t slen;
size_t len;
- int error = 0;
+ int error = copyoutstr_prevalidate(from, to, maxlen);
+
+ if (__improbable(error)) {
+ return error;
+ }
slen = strlen(from) + 1;
- if (slen > maxlen)
+ if (slen > maxlen) {
error = ENAMETOOLONG;
+ }
- len = min(maxlen, slen);
- if (copyout(from, to, len))
+ len = MIN(maxlen, slen);
+ if (copyout(from, to, len)) {
error = EFAULT;
+ }
*lencopied = len;
return error;
for (l = 0; l < maxlen; l++) {
if ((*to++ = *from++) == '\0') {
- if (lencopied)
+ if (lencopied) {
*lencopied = l + 1;
+ }
return 0;
}
}
- if (lencopied)
+ if (lencopied) {
*lencopied = maxlen;
+ }
return ENAMETOOLONG;
}
bcopy(src, dst, count);
return 0;
}
+