Ticket #582: pr582.diff

File pr582.diff, 4.8 KB (added by Joel Sherrill, on Dec 3, 2006 at 1:31:13 PM)

pr582.diff

  • posix/src/mqueue.c

    RCS file: /usr1/CVS/rtems/cpukit/posix/src/mqueue.c,v
    retrieving revision 1.15
    diff -u -r1.15 mqueue.c
     
    2525#include <errno.h>
    2626#include <fcntl.h>
    2727#include <mqueue.h>
     28#include <limits.h>
    2829
    2930#include <rtems/system.h>
    3031#include <rtems/score/watchdog.h>
     
    7071    maximum_message_queues,
    7172    sizeof( POSIX_Message_queue_Control_fd ),
    7273                                /* size of this object's control block */
    73     FALSE,                      /* TRUE if names for this object are strings */
    74     0                           /* maximum length of each object's name */
     74    TRUE,                       /* TRUE if names for this object are strings */
     75    NAME_MAX                    /* maximum length of each object's name */
    7576#if defined(RTEMS_MULTIPROCESSING)
    7677    ,
    7778    FALSE,                      /* TRUE if this is a global object class */
  • posix/src/mqueuecreatesupp.c

    RCS file: /usr1/CVS/rtems/cpukit/posix/src/mqueuecreatesupp.c,v
    retrieving revision 1.12
    diff -u -r1.12 mqueuecreatesupp.c
     
    1818#include "config.h"
    1919#endif
    2020
     21#include <string.h>
    2122#include <stdarg.h>
    2223#include <stdlib.h>
    2324
     
    2930
    3031#include <rtems/system.h>
    3132#include <rtems/score/watchdog.h>
     33#include <rtems/score/wkspace.h>
    3234#include <rtems/seterr.h>
    3335#include <rtems/posix/mqueue.h>
    3436#include <rtems/posix/time.h>
    3537
     38/* pure ANSI mode does not have this prototype */
     39size_t strnlen(const char *, size_t);
     40
    3641/*PAGE
    3742 *
    3843 *  _POSIX_Message_queue_Create_support
     
    4247 */
    4348 
    4449int _POSIX_Message_queue_Create_support(
    45   const char                    *_name,
     50  const char                    *name_arg,
    4651  int                            pshared,
    4752  struct mq_attr                *attr_ptr,
    4853  POSIX_Message_queue_Control  **message_queue
     
    5156  POSIX_Message_queue_Control   *the_mq;
    5257  CORE_message_queue_Attributes *the_mq_attr;
    5358  struct mq_attr                 attr;
    54   char *name;
     59  char                          *name;
     60  size_t                         n;
     61
     62  n = strnlen( name_arg, NAME_MAX );
     63  if ( n > NAME_MAX )
     64    return ENAMETOOLONG;
    5565
    5666  _Thread_Disable_dispatch();
    5767 
     
    100110  the_mq->open_count = 1;
    101111  the_mq->linked = TRUE;
    102112
     113  /*
     114   * Make a copy of the user's string for name just in case it was
     115   * dynamically constructed.
     116   */
     117
     118  name = _Workspace_Allocate(n);
     119  if (!name) {
     120    _POSIX_Message_queue_Free( the_mq );
     121    _Thread_Enable_dispatch();
     122    rtems_set_errno_and_return_minus_one( ENOMEM );
     123  }
     124  strcpy( name, name_arg );
    103125 
    104126  /* XXX
    105127   *
     
    123145#endif
    124146 
    125147    _POSIX_Message_queue_Free( the_mq );
     148    _Workspace_Free(name);
    126149    _Thread_Enable_dispatch();
    127150    rtems_set_errno_and_return_minus_one( ENOSPC );
    128151  }
    129152
    130   name = malloc(256);
    131   strcpy( name, _name );
    132153  _Objects_Open(
    133154    &_POSIX_Message_queue_Information,
    134155    &the_mq->Object,
  • posix/src/mqueuedeletesupp.c

    RCS file: /usr1/CVS/rtems/cpukit/posix/src/mqueuedeletesupp.c,v
    retrieving revision 1.6
    diff -u -r1.6 mqueuedeletesupp.c
     
    2828
    2929#include <rtems/system.h>
    3030#include <rtems/score/watchdog.h>
     31#include <rtems/score/wkspace.h>
    3132#include <rtems/seterr.h>
    3233#include <rtems/posix/mqueue.h>
    3334#include <rtems/posix/time.h>
     
    4243)
    4344{
    4445  if ( !the_mq->linked && !the_mq->open_count ) {
     46      /* the name memory may have been freed by unlink. */
     47      if ( the_mq->Object.name )
     48        _Workspace_Free( the_mq->Object.name );
     49
    4550      _Objects_Close( &_POSIX_Message_queue_Information, &the_mq->Object );
    4651 
    4752      _CORE_message_queue_Close(
  • posix/src/mqueueunlink.c

    RCS file: /usr1/CVS/rtems/cpukit/posix/src/mqueueunlink.c,v
    retrieving revision 1.8
    diff -u -r1.8 mqueueunlink.c
     
    2828
    2929#include <rtems/system.h>
    3030#include <rtems/score/watchdog.h>
     31#include <rtems/score/wkspace.h>
    3132#include <rtems/seterr.h>
    3233#include <rtems/posix/mqueue.h>
    3334#include <rtems/posix/time.h>
     
    7576
    7677 
    7778  the_mq->linked = FALSE;
     79  _Workspace_Free( the_mq->Object.name );
    7880  _POSIX_Message_queue_Namespace_remove( the_mq );
    7981  _POSIX_Message_queue_Delete( the_mq );
    8082