Changeset View
Changeset View
Standalone View
Standalone View
sys/compat/linuxkpi/common/include/linux/string.h
| Context not available. | |||||
| return (dst); | return (dst); | ||||
| } | } | ||||
| static inline char * | |||||
| strndup_user(const char __user *ustr, long n) | |||||
| { | |||||
| char *kstr; | |||||
| if (ustr == NULL) | |||||
| return (ERR_PTR(-EFAULT)); | |||||
markj: There's no need for this check, memdup_user() will handle it. A user-supplied pointer can never… | |||||
| if (n < 1) | |||||
Done Inline ActionsI think "n" excludes the NUL character. Why can't you simply do: return (memdup_user_nul(ustr, n)); hselasky: I think "n" excludes the NUL character.
Why can't you simply do:
```
return (memdup_user_nul… | |||||
| return (ERR_PTR(-EINVAL)); | |||||
| kstr = memdup_user(ustr, n); | |||||
| if (IS_ERR(kstr)) | |||||
| return (kstr); | |||||
| kstr[n-1] = '\0'; | |||||
| return (kstr); | |||||
| } | |||||
| static inline char * | static inline char * | ||||
| kstrdup(const char *string, gfp_t gfp) | kstrdup(const char *string, gfp_t gfp) | ||||
| { | { | ||||
| Context not available. | |||||
There's no need for this check, memdup_user() will handle it. A user-supplied pointer can never be trusted, so there's no real reason to check for NULL specifically (it could be 0x1, or any other invalid value).