Changeset 7faabb7 in mainline for kernel/generic/src/proc/thread.c


Ignore:
Timestamp:
2008-11-07T23:16:28Z (16 years ago)
Author:
Jiri Svoboda <jirik.svoboda@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
24345a5
Parents:
86e3d62
Message:

Fix sys_thread_create(): could fail when passed name was at end of mapping, could crash if provided name was not null-terminated.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/proc/thread.c

    r86e3d62 r7faabb7  
    709709 */
    710710unative_t sys_thread_create(uspace_arg_t *uspace_uarg, char *uspace_name,
    711     thread_id_t *uspace_thread_id)
     711    size_t name_len, thread_id_t *uspace_thread_id)
    712712{
    713713        thread_t *t;
     
    716716        int rc;
    717717
    718         rc = copy_from_uspace(namebuf, uspace_name, THREAD_NAME_BUFLEN);
     718        if (name_len >= THREAD_NAME_BUFLEN)
     719                name_len = THREAD_NAME_BUFLEN - 1;
     720
     721        rc = copy_from_uspace(namebuf, uspace_name, name_len);
    719722        if (rc != 0)
    720723                return (unative_t) rc;
     724
     725        namebuf[name_len] = '\0';
    721726
    722727        /*
Note: See TracChangeset for help on using the changeset viewer.