Skip to content

Commit 5b6b279

Browse files
kevin-brodsky-armakpm00
authored andcommitted
selftests/mm: fix strncpy() length
GCC complains (with -O2) that the length is equal to the destination size, which is indeed invalid. Subtract 1 from the size of the array to leave room for '\0'. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Kevin Brodsky <[email protected]> Cc: Aruna Ramakrishna <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Joey Gouly <[email protected]> Cc: Keith Lucas <[email protected]> Cc: Ryan Roberts <[email protected]> Cc: Shuah Khan <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 516fb51 commit 5b6b279

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/testing/selftests/mm/write_to_hugetlbfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ int main(int argc, char **argv)
8989
size = atoi(optarg);
9090
break;
9191
case 'p':
92-
strncpy(path, optarg, sizeof(path));
92+
strncpy(path, optarg, sizeof(path) - 1);
9393
break;
9494
case 'm':
9595
if (atoi(optarg) >= MAX_METHOD) {

0 commit comments

Comments
 (0)