From 69a294cd641c623db61f46ee86901845789a1c7b Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Thu, 2 Jan 2014 01:16:33 +0000 Subject: [PATCH] sched: Dont use fixed-size buffer for task names. This is not more complicated than the strncpy(), and it allows for arbitrary long task names. --- sched.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sched.c b/sched.c index b92774fa..0a1cff28 100644 --- a/sched.c +++ b/sched.c @@ -20,7 +20,7 @@ struct task { /** The task name supplied when the task was registered(). */ - char name[255]; + char *name; /** Copied from the task_info struct during task_register(). */ void (*pre_select)(struct sched *s, struct task *t); /** Copied from the task_info struct during task_register(). */ @@ -64,6 +64,7 @@ static void unlink_and_free_task(struct task *t) { PARA_INFO_LOG("freeing task %s\n", t->name); list_del(&t->node); + free(t->name); free(t); } @@ -239,8 +240,7 @@ struct task *task_register(struct task_info *info, struct sched *s) if (!s->task_list.next) INIT_LIST_HEAD(&s->task_list); - snprintf(t->name, sizeof(t->name) - 1, "%s", info->name); - t->name[sizeof(t->name) - 1] = '\0'; + t->name = para_strdup(info->name); t->notification = 0; t->status = 0; t->dead = false; -- 2.39.2