diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2010-08-25 21:17:03 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2010-08-25 21:17:03 +0000 |
commit | 39aa5cfae0fc2b8ed2d3dab822efb84c9d6a1671 (patch) | |
tree | 8aaa7fd0c57b605b220cec6769a340479cbdc796 | |
parent | 2010-08-25 Joel Sherrill <joel.sherrill@oarcorp.com> (diff) | |
download | rtems-39aa5cfae0fc2b8ed2d3dab822efb84c9d6a1671.tar.bz2 |
2010-08-25 Joel Sherrill <joel.sherrill@oarcorp.com>
Coverity Id 125
Coverity Id 126
* libi2c/libi2c.c: Use strncpy and snprintf.
-rw-r--r-- | cpukit/ChangeLog | 6 | ||||
-rw-r--r-- | cpukit/libi2c/libi2c.c | 10 |
2 files changed, 12 insertions, 4 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index 2f190159b1..6a56a8e09a 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,5 +1,11 @@ 2010-08-25 Joel Sherrill <joel.sherrill@oarcorp.com> + Coverity Id 125 + Coverity Id 126 + * libi2c/libi2c.c: Use strncpy and snprintf. + +2010-08-25 Joel Sherrill <joel.sherrill@oarcorp.com> + * score/src/coremsginsert.c: Fix typo. 2010-08-25 Joel Sherrill <joel.sherrill@oarcorp.com> diff --git a/cpukit/libi2c/libi2c.c b/cpukit/libi2c/libi2c.c index f6b3fe8416..1f88968aab 100644 --- a/cpukit/libi2c/libi2c.c +++ b/cpukit/libi2c/libi2c.c @@ -385,7 +385,8 @@ rtems_libi2c_register_bus (const char *name, rtems_libi2c_bus_t * bus) { int i; rtems_status_code err; - char *nmcpy = malloc (name ? strlen (name) + 1 : 20); + size_t length = (name ? strlen (name) + 1 : 20); + char *nmcpy = malloc(length); char tmp, *chpt; struct stat sbuf; @@ -394,7 +395,7 @@ rtems_libi2c_register_bus (const char *name, rtems_libi2c_bus_t * bus) return -RTEMS_NO_MEMORY; } - strcpy (nmcpy, name ? name : "/dev/i2c"); + strncpy (nmcpy, name ? name : "/dev/i2c", length); /* check */ if ('/' != *nmcpy) { @@ -737,8 +738,9 @@ rtems_libi2c_register_drv (const char *name, rtems_libi2c_drv_t * drvtbl, minor = ((i + 1) << 13) | RTEMS_LIBI2C_MAKE_MINOR (busno, i2caddr); if (name) { - str = malloc (strlen (busses[busno].name) + strlen (name) + 2); - sprintf (str, "%s.%s", busses[busno].name, name); + size_t length = strlen (busses[busno].name) + strlen (name) + 2; + str = malloc (length); + snprintf (str, length, "%s.%s", busses[busno].name, name); dev = rtems_filesystem_make_dev_t (rtems_libi2c_major, minor); |