proc_test: use snprintf() instead of sprintf().
authorarighi <arighi@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 17 Mar 2010 15:39:08 +0000 (15:39 +0000)
committerarighi <arighi@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 17 Mar 2010 15:39:08 +0000 (15:39 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3229 38d2e660-2303-0410-9eaa-f027e97ec537

bertos/kern/proc_test.c

index b7e385a5973d3dd9d267b8d9465ae542a105c2a1..63123237f2a5a6944985e79533151b47438a8888 100644 (file)
@@ -125,7 +125,8 @@ static int worker_test(void)
        kputs("Run Proc test..\n");
        for (i = 0; i < TASKS; i++)
        {
-               sprintf(&name[i][0], "worker_%zd", i + 1);
+               snprintf(&name[i][0], sizeof(name[i]), "worker_%zd", i + 1);
+               name[i][sizeof(name) - 1] = '\0';
                proc_new_with_name(name[i], worker, (iptr_t)(i + 1),
                                WORKER_STACK_SIZE, &worker_stack[i][0]);
        }
@@ -202,7 +203,9 @@ static int preempt_worker_test(void)
        kputs("Run Preemption test..\n");
        for (i = 0; i < TASKS; i++)
        {
-               sprintf(&preempt_name[i][0], "preempt_worker_%zd", i + 1);
+               snprintf(&preempt_name[i][0], sizeof(preempt_name[i]),
+                               "preempt_worker_%zd", i + 1);
+               preempt_name[i][sizeof(preempt_name) - 1] = '\0';
                proc_new_with_name(preempt_name[i], preempt_worker, (iptr_t)(i + 1),
                                WORKER_STACK_SIZE, &preempt_worker_stack[i][0]);
        }