Changeset 39aa5cfa in rtems


Ignore:
Timestamp:
Aug 25, 2010, 9:17:03 PM (9 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.11, master
Children:
ae336ea
Parents:
49460dc
Message:

2010-08-25 Joel Sherrill <joel.sherrill@…>

Coverity Id 125
Coverity Id 126

  • libi2c/libi2c.c: Use strncpy and snprintf.
Location:
cpukit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    r49460dc r39aa5cfa  
     12010-08-25      Joel Sherrill <joel.sherrill@oarcorp.com>
     2
     3        Coverity Id 125
     4        Coverity Id 126
     5        * libi2c/libi2c.c: Use strncpy and snprintf.
     6
    172010-08-25      Joel Sherrill <joel.sherrill@oarcorp.com>
    28
  • cpukit/libi2c/libi2c.c

    r49460dc r39aa5cfa  
    386386  int i;
    387387  rtems_status_code err;
    388   char *nmcpy = malloc (name ? strlen (name) + 1 : 20);
     388  size_t length = (name ? strlen (name) + 1 : 20);
     389  char *nmcpy = malloc(length);
    389390  char tmp, *chpt;
    390391  struct stat sbuf;
     
    395396  }
    396397
    397   strcpy (nmcpy, name ? name : "/dev/i2c");
     398  strncpy (nmcpy, name ? name : "/dev/i2c", length);
    398399
    399400  /* check */
     
    738739
    739740      if (name) {
    740         str = malloc (strlen (busses[busno].name) + strlen (name) + 2);
    741         sprintf (str, "%s.%s", busses[busno].name, name);
     741        size_t length = strlen (busses[busno].name) + strlen (name) + 2;
     742        str = malloc (length);
     743        snprintf (str, length, "%s.%s", busses[busno].name, name);
    742744
    743745        dev = rtems_filesystem_make_dev_t (rtems_libi2c_major, minor);
Note: See TracChangeset for help on using the changeset viewer.