From 2d17fe736f79860237d8a05c57f9aabcfdab4c87 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Tue, 8 Nov 2022 22:51:36 -0500 Subject: [PATCH] =?UTF-8?q?[kernel]=20=E4=BF=AE=E6=AD=A3=E5=A4=8D=E5=88=B6?= =?UTF-8?q?name=E5=AD=97=E6=AE=B5=E6=97=B6=E6=BD=9C=E5=9C=A8=E7=9A=84?= =?UTF-8?q?=E5=86=85=E5=AD=98=E8=B8=A9=E8=B8=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/object.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/object.c b/src/object.c index cb177edbe6..fa14bcb7a2 100644 --- a/src/object.c +++ b/src/object.c @@ -366,7 +366,8 @@ void rt_object_init(struct rt_object *object, /* set object type to static */ object->type = type | RT_Object_Class_Static; /* copy name */ - rt_strncpy(object->name, name, RT_NAME_MAX); + rt_strncpy(object->name, name, RT_NAME_MAX - 1); + object->name[RT_NAME_MAX - 1] = '\0'; RT_OBJECT_HOOK_CALL(rt_object_attach_hook, (object));