diff --git a/sys/compat/linuxkpi/common/include/linux/string.h b/sys/compat/linuxkpi/common/include/linux/string.h --- a/sys/compat/linuxkpi/common/include/linux/string.h +++ b/sys/compat/linuxkpi/common/include/linux/string.h @@ -98,6 +98,23 @@ return (dst); } +static inline char * +strndup_user(const char __user *ustr, long n) +{ + char *kstr; + + if (n < 1) + return (ERR_PTR(-EINVAL)); + + kstr = memdup_user(ustr, n); + if (IS_ERR(kstr)) + return (kstr); + + kstr[n-1] = '\0'; + + return (kstr); +} + static inline char * kstrdup(const char *string, gfp_t gfp) {