diff --git a/components/libc/posix/libdl/dlmodule.c b/components/libc/posix/libdl/dlmodule.c index 269e7bc4333..17aca0b2da8 100644 --- a/components/libc/posix/libdl/dlmodule.c +++ b/components/libc/posix/libdl/dlmodule.c @@ -55,7 +55,7 @@ static void _dlmodule_set_name(struct rt_dlmodule *module, const char *path) } size = end - first + 1; - if (size > RT_NAME_MAX) size = RT_NAME_MAX; + if (size >= RT_NAME_MAX) size = RT_NAME_MAX - 1; rt_strncpy(object->name, first, size); object->name[size] = '\0';