[kernel] 修正复制name字段时潜在的内存踩踏问题
This commit is contained in:
parent
a6151716b2
commit
2d17fe736f
|
@ -366,7 +366,8 @@ void rt_object_init(struct rt_object *object,
|
||||||
/* set object type to static */
|
/* set object type to static */
|
||||||
object->type = type | RT_Object_Class_Static;
|
object->type = type | RT_Object_Class_Static;
|
||||||
/* copy name */
|
/* 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));
|
RT_OBJECT_HOOK_CALL(rt_object_attach_hook, (object));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue