*
*/
+#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/ioctl.h>
{
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))
+ 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;
}