From: Quanyang Wang <[email protected]>
In yaffs_fix_null_name, "if (strnlen(name, YAFFS_MAX_NAME_LENGTH) == 0)"
is used to judge if the "name" string is zero length. But this is wrong
when the "name" char array size is less than YAFFS_MAX_NAME_LENGTH and
this will trigger compile warnig as below:
fs/yaffs2/yaffs_guts.c:4501:13: warning: ‘strnlen’ specified bound 255 exceeds
source size 16 [-Wstringop-overread]
4501 | if (strnlen(name, YAFFS_MAX_NAME_LENGTH) == 0) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Let's use buffer_size to do this instead of YAFFS_MAX_NAME_LENGTH
because buffer_size is passed to yaffs_fix_null_name by caller with
appropriate value which is fixed to the size of "name" char array.
Signed-off-by: Quanyang Wang <[email protected]>
---
fs/yaffs2/yaffs_guts.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/yaffs2/yaffs_guts.c b/fs/yaffs2/yaffs_guts.c
index 40a5b46cf6caf..0cc794ebc347f 100644
--- a/fs/yaffs2/yaffs_guts.c
+++ b/fs/yaffs2/yaffs_guts.c
@@ -4498,7 +4498,7 @@ static void yaffs_fix_null_name(struct yaffs_obj *obj,
YCHAR *name,
int buffer_size)
{
/* Create an object name if we could not find one. */
- if (strnlen(name, YAFFS_MAX_NAME_LENGTH) == 0) {
+ if (strnlen(name, buffer_size) == 0) {
YCHAR local_name[20];
YCHAR num_string[20];
YCHAR *x = &num_string[19];
--
2.25.1
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#9964):
https://lists.yoctoproject.org/g/linux-yocto/message/9964
Mute This Topic: https://lists.yoctoproject.org/mt/83503374/21656
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-