Skip to content

Commit 0fdbe84

Browse files
tobluxjankara
authored andcommitted
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: Thorsten Blum <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jan Kara <[email protected]>
1 parent 4520b96 commit 0fdbe84

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

fs/notify/fanotify/fanotify.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <linux/fsnotify_backend.h>
33
#include <linux/path.h>
44
#include <linux/slab.h>
5+
#include <linux/string.h>
56
#include <linux/exportfs.h>
67
#include <linux/hashtable.h>
78

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

220221
info->name_len = name->len;
221-
strcpy(fanotify_info_name(info), name->name);
222+
strscpy(fanotify_info_name(info), name->name, name->len + 1);
222223
}
223224

224225
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,
228229
return;
229230

230231
info->name2_len = name->len;
231-
strcpy(fanotify_info_name2(info), name->name);
232+
strscpy(fanotify_info_name2(info), name->name, name->len + 1);
232233
}
233234

234235
/*

0 commit comments

Comments
 (0)