Skip to contentSkip to conversation

kernel/params.c: fix the maximum length in param_get_string

PATCH New [email protected] 1 participant 1 message Oct 3, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 45/51 kernel/params.c: fix the maximum length in param_get_string

From: Jean Delvare <[email protected]>
Subject: kernel/params.c: fix the maximum length in param_get_string

The length parameter of strlcpy() is supposed to reflect the size of the target buffer, not of the source string. Harmless in this case as the buffer is PAGE_SIZE long and the source string is always much shorter than this, but conceptually wrong, so let's fix it.

---

 kernel/params.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/params.c renamed from kernel/params.c~params-fix-the-maximum-length-in-param_get_string +1 -1
diff -puN kernel/params.c~params-fix-the-maximum-length-in-param_get_string kernel/params.c
@@ -507,7 +507,7 @@ EXPORT_SYMBOL(param_set_copystring);
 int param_get_string(char *buffer, const struct kernel_param *kp)
 {
 	const struct kparam_string *kps = kp->str;
-	return strlcpy(buffer, kps->string, kps->maxlen);
+	return strlcpy(buffer, kps->string, PAGE_SIZE);
 }
 EXPORT_SYMBOL(param_get_string);
 

_