diff options
author | nectar <nectar@FreeBSD.org> | 2003-04-29 21:13:50 +0000 |
---|---|---|
committer | nectar <nectar@FreeBSD.org> | 2003-04-29 21:13:50 +0000 |
commit | e69967f5348cec651f8806d25d2c59ac8ed8c2a2 (patch) | |
tree | e9749f1ff2693755bce73e10528fc8cc6a6563ea /lib/libc/gen/fmtmsg.c | |
parent | 975e4bcef1ba69d85a5c90f1849accc3cd74cb65 (diff) | |
download | FreeBSD-src-e69967f5348cec651f8806d25d2c59ac8ed8c2a2.zip FreeBSD-src-e69967f5348cec651f8806d25d2c59ac8ed8c2a2.tar.gz |
`Hide' strlcpy and strlcat (using the namespace.h / __weak_reference
technique) so that we don't wind up calling into an application's
version if the application defines them.
Inspired by: qpopper's interfering and buggy version of strlcpy
Diffstat (limited to 'lib/libc/gen/fmtmsg.c')
-rw-r--r-- | lib/libc/gen/fmtmsg.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/libc/gen/fmtmsg.c b/lib/libc/gen/fmtmsg.c index 6caabbb..a9b4e60 100644 --- a/lib/libc/gen/fmtmsg.c +++ b/lib/libc/gen/fmtmsg.c @@ -27,10 +27,12 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include "namespace.h" #include <fmtmsg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "un-namespace.h" /* Default value for MSGVERB. */ #define DFLT_MSGVERB "label:severity:text:action:tag" @@ -101,13 +103,13 @@ def: #define INSERT_COLON \ if (*output != '\0') \ - strlcat(output, ": ", size) + _strlcat(output, ": ", size) #define INSERT_NEWLINE \ if (*output != '\0') \ - strlcat(output, "\n", size) + _strlcat(output, "\n", size) #define INSERT_SPACE \ if (*output != '\0') \ - strlcat(output, " ", size) + _strlcat(output, " ", size) /* * Returns NULL on memory allocation failure, otherwise returns a pointer to @@ -139,20 +141,20 @@ printfmt(char *msgverb, long class, const char *label, int sev, while ((comp = nextcomp(msgverb)) != NULL) { if (strcmp(comp, "label") == 0 && label != MM_NULLLBL) { INSERT_COLON; - strlcat(output, label, size); + _strlcat(output, label, size); } else if (strcmp(comp, "severity") == 0 && sevname != NULL) { INSERT_COLON; - strlcat(output, sevinfo(sev), size); + _strlcat(output, sevinfo(sev), size); } else if (strcmp(comp, "text") == 0 && text != MM_NULLTXT) { INSERT_COLON; - strlcat(output, text, size); + _strlcat(output, text, size); } else if (strcmp(comp, "action") == 0 && act != MM_NULLACT) { INSERT_NEWLINE; - strlcat(output, "TO FIX: ", size); - strlcat(output, act, size); + _strlcat(output, "TO FIX: ", size); + _strlcat(output, act, size); } else if (strcmp(comp, "tag") == 0 && tag != MM_NULLTAG) { INSERT_SPACE; - strlcat(output, tag, size); + _strlcat(output, tag, size); } } INSERT_NEWLINE; @@ -171,7 +173,7 @@ nextcomp(const char *msgverb) char *retval; if (*lmsgverb == '\0') { - strlcpy(lmsgverb, msgverb, sizeof(lmsgverb)); + _strlcpy(lmsgverb, msgverb, sizeof(lmsgverb)); retval = strtok_r(lmsgverb, ":", &state); } else { retval = strtok_r(NULL, ":", &state); |