diff options
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2002-10-16 10:14:14 (GMT) |
---|---|---|
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2002-10-16 10:14:14 (GMT) |
commit | defaea533516de75e361227996be5fc8de134306 (patch) | |
tree | 35caf30542f90fad01a4e672a311c3e59b35d4c1 | |
parent | 26af21dad2563fbdbd1de80d26dce6ec5bb43e3d (diff) | |
download | monitoring-plugins-defaea533516de75e361227996be5fc8de134306.tar.gz |
use asprintf to construct strscat
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@118 f882894a-f735-0410-b71e-b25c423dba1c
-rw-r--r-- | plugins/utils.c | 21 |
1 files changed, 2 insertions, 19 deletions
diff --git a/plugins/utils.c b/plugins/utils.c index 6e52dab..05d3f79 100644 --- a/plugins/utils.c +++ b/plugins/utils.c | |||
@@ -415,26 +415,9 @@ strscpy (char *dest, const char *src) | |||
415 | char * | 415 | char * |
416 | strscat (char *dest, const char *src) | 416 | strscat (char *dest, const char *src) |
417 | { | 417 | { |
418 | size_t len, l2; | ||
419 | |||
420 | if (src == NULL) | ||
421 | return dest; | ||
422 | else | ||
423 | l2 = strlen (src); | ||
424 | |||
425 | if (dest == NULL) { | ||
426 | len = 0; | ||
427 | dest = malloc (l2 + 1); | ||
428 | } else { | ||
429 | len = strlen (dest); | ||
430 | dest = realloc (dest, len + l2 + 1); | ||
431 | } | ||
432 | 418 | ||
433 | if (dest == NULL) | 419 | if (src != NULL) |
434 | terminate (STATE_UNKNOWN, "failed malloc in strscat\n"); | 420 | asprintf (&dest, "%s%s", dest, src); |
435 | |||
436 | strncpy (dest + len, src, l2); | ||
437 | dest[len + l2] = '\0'; | ||
438 | 421 | ||
439 | return dest; | 422 | return dest; |
440 | } | 423 | } |