Security: replace all uses of strcat and strcpy with strncat and strncpy
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: gnu_linux.c,v 1.19 2005/11/07 07:41:29 rocky Exp $
|
||||
$Id: gnu_linux.c,v 1.20 2006/03/18 00:53:20 rocky Exp $
|
||||
|
||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||
Copyright (C) 2002, 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||
@@ -27,7 +27,7 @@
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
static const char _rcsid[] = "$Id: gnu_linux.c,v 1.19 2005/11/07 07:41:29 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: gnu_linux.c,v 1.20 2006/03/18 00:53:20 rocky Exp $";
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -140,20 +140,24 @@ check_mounts_linux(const char *mtab)
|
||||
char *tmp;
|
||||
char *mnt_type;
|
||||
char *mnt_dev;
|
||||
unsigned int i_mnt_type;
|
||||
unsigned int i_mnt_dev;
|
||||
|
||||
while ( (mntent=getmntent(mntfp)) != NULL ) {
|
||||
mnt_type = malloc(strlen(mntent->mnt_type) + 1);
|
||||
i_mnt_type = strlen(mntent->mnt_type) + 1;
|
||||
mnt_type = calloc(1, i_mnt_type);
|
||||
if (mnt_type == NULL)
|
||||
continue; /* maybe you'll get lucky next time. */
|
||||
|
||||
mnt_dev = malloc(strlen(mntent->mnt_fsname) + 1);
|
||||
i_mnt_dev = strlen(mntent->mnt_fsname) + 1;
|
||||
mnt_dev = calloc(1, i_mnt_dev);
|
||||
if (mnt_dev == NULL) {
|
||||
free(mnt_type);
|
||||
continue;
|
||||
}
|
||||
|
||||
strcpy(mnt_type, mntent->mnt_type);
|
||||
strcpy(mnt_dev, mntent->mnt_fsname);
|
||||
strncpy(mnt_type, mntent->mnt_type, i_mnt_type);
|
||||
strncpy(mnt_dev, mntent->mnt_fsname, i_mnt_dev);
|
||||
|
||||
/* Handle "supermount" filesystem mounts */
|
||||
if ( strcmp(mnt_type, "supermount") == 0 ) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: util.c,v 1.2 2005/02/03 07:35:15 rocky Exp $
|
||||
$Id: util.c,v 1.3 2006/03/18 00:53:20 rocky Exp $
|
||||
|
||||
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
|
||||
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||
@@ -36,7 +36,7 @@
|
||||
#include <cdio/types.h>
|
||||
#include <cdio/util.h>
|
||||
|
||||
static const char _rcsid[] = "$Id: util.c,v 1.2 2005/02/03 07:35:15 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: util.c,v 1.3 2006/03/18 00:53:20 rocky Exp $";
|
||||
|
||||
size_t
|
||||
_cdio_strlenv(char **str_array)
|
||||
@@ -64,36 +64,6 @@ _cdio_strfreev(char **strv)
|
||||
free(strv);
|
||||
}
|
||||
|
||||
char *
|
||||
_cdio_strjoin (char *strv[], unsigned count, const char delim[])
|
||||
{
|
||||
size_t len;
|
||||
char *new_str;
|
||||
unsigned n;
|
||||
|
||||
cdio_assert (strv != NULL);
|
||||
cdio_assert (delim != NULL);
|
||||
|
||||
len = (count-1) * strlen (delim);
|
||||
|
||||
for (n = 0;n < count;n++)
|
||||
len += strlen (strv[n]);
|
||||
|
||||
len++;
|
||||
|
||||
new_str = calloc (1, len);
|
||||
new_str[0] = '\0';
|
||||
|
||||
for (n = 0;n < count;n++)
|
||||
{
|
||||
if (n)
|
||||
strcat (new_str, delim);
|
||||
strcat (new_str, strv[n]);
|
||||
}
|
||||
|
||||
return new_str;
|
||||
}
|
||||
|
||||
char **
|
||||
_cdio_strsplit(const char str[], char delim) /* fixme -- non-reentrant */
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user