Commit 0fdbe845 authored by Thorsten Blum's avatar Thorsten Blum Committed by Jan Kara
Browse files

fanotify: replace deprecated strcpy in fanotify_info_copy_{name,name2}

strcpy() has been deprecated [1] because it performs no bounds checking
on the destination buffer, which can lead to buffer overflows. Replace
it with the safer strscpy().

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy

 [1]
Signed-off-by: default avatarThorsten Blum <thorsten.blum@linux.dev>
Link: https://patch.msgid.link/20260321210544.519259-4-thorsten.blum@linux.dev


Signed-off-by: default avatarJan Kara <jack@suse.cz>
parent 4520b96b
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
#include <linux/fsnotify_backend.h>
#include <linux/path.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/exportfs.h>
#include <linux/hashtable.h>

@@ -218,7 +219,7 @@ static inline void fanotify_info_copy_name(struct fanotify_info *info,
		return;

	info->name_len = name->len;
	strcpy(fanotify_info_name(info), name->name);
	strscpy(fanotify_info_name(info), name->name, name->len + 1);
}

static inline void fanotify_info_copy_name2(struct fanotify_info *info,
@@ -228,7 +229,7 @@ static inline void fanotify_info_copy_name2(struct fanotify_info *info,
		return;

	info->name2_len = name->len;
	strcpy(fanotify_info_name2(info), name->name);
	strscpy(fanotify_info_name2(info), name->name, name->len + 1);
}

/*