include strlcpy and *printf and use them

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@14930 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2005-04-24 19:43:06 +00:00
parent da6cb81649
commit ddb34e00b3
4 changed files with 40 additions and 8 deletions

View File

@@ -51,15 +51,14 @@ error_message (long code)
const char *p = com_right(_et_list, code);
if (p == NULL) {
if (code < 0)
sprintf(msg, "Unknown error %ld", code);
snprintf(msg, sizeof(msg), "Unknown error %ld", code);
else
p = strerror(code);
}
if (p != NULL && *p != '\0') {
strncpy(msg, p, sizeof(msg) - 1);
msg[sizeof(msg) - 1] = 0;
strlcpy(msg, p, sizeof(msg));
} else
sprintf(msg, "Unknown error %ld", code);
snprintf(msg, sizeof(msg), "Unknown error %ld", code);
return msg;
}