mirror of
https://github.com/monitoring-plugins/monitoring-plugins.git
synced 2026-05-28 04:35:40 -04:00
use asprintf to construct strscat
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@118 f882894a-f735-0410-b71e-b25c423dba1c
This commit is contained in:
parent
26af21dad2
commit
defaea5335
1 changed files with 2 additions and 19 deletions
|
|
@ -415,26 +415,9 @@ strscpy (char *dest, const char *src)
|
|||
char *
|
||||
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';
|
||||
if (src != NULL)
|
||||
asprintf (&dest, "%s%s", dest, src);
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue