Changeset 7faabb7 in mainline


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.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/proc/thread.h

    r86e3d62 r7faabb7  
    260260
    261261/* Thread syscall prototypes. */
    262 extern unative_t sys_thread_create(uspace_arg_t *uspace_uarg, char *uspace_name, thread_id_t *uspace_thread_id);
     262extern unative_t sys_thread_create(uspace_arg_t *uspace_uarg,
     263    char *uspace_name, size_t name_len, thread_id_t *uspace_thread_id);
    263264extern unative_t sys_thread_exit(int uspace_status);
    264265extern unative_t sys_thread_get_id(thread_id_t *uspace_thread_id);
  • 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        /*
  • uspace/lib/libc/generic/thread.c

    r86e3d62 r7faabb7  
    109109        uarg->uspace_uarg = uarg;
    110110       
    111         rc = __SYSCALL3(SYS_THREAD_CREATE, (sysarg_t) uarg, (sysarg_t) name,
    112             (sysarg_t) tid);
     111        rc = __SYSCALL4(SYS_THREAD_CREATE, (sysarg_t) uarg, (sysarg_t) name,
     112            (sysarg_t) strlen(name), (sysarg_t) tid);
    113113       
    114114        if (rc) {
Note: See TracChangeset for help on using the changeset viewer.