[Nagiosplug-checkins] CVS: nagiosplug/plugins utils.c,1.4,1.5

Karl DeBisschop kdebisschop at users.sourceforge.net
Wed Oct 16 03:15:02 CEST 2002


Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory usw-pr-cvs1:/tmp/cvs-serv30238/plugins

Modified Files:
	utils.c 
Log Message:
use asprintf to construct strscat

Index: utils.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/utils.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** utils.c	16 Oct 2002 04:56:19 -0000	1.4
--- utils.c	16 Oct 2002 10:14:14 -0000	1.5
***************
*** 416,439 ****
  strscat (char *dest, const char *src)
  {
- 	size_t len, l2;
  
! 	if (src == NULL)
! 		return dest;
! 	else
! 		l2 = strlen (src);
! 
! 	if (dest == NULL) {
! 		len = 0;
! 		dest = malloc (l2 + 1);
! 	} else {
! 		len = strlen (dest);
! 		dest = realloc (dest, len + l2 + 1);
! 	}
! 
! 	if (dest == NULL)
! 		terminate (STATE_UNKNOWN, "failed malloc in strscat\n");
! 
! 	strncpy (dest + len, src, l2);
! 	dest[len + l2] = '\0';
  
  	return dest;
--- 416,422 ----
  strscat (char *dest, const char *src)
  {
  
! 	if (src != NULL)
! 		asprintf (&dest, "%s%s", dest, src);
  
  	return dest;





More information about the Commits mailing list