merge strcpy_truncate branch

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@5027 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Johan Danielsson
1998-06-09 19:25:40 +00:00
parent e255dfc950
commit a5f54865d4
87 changed files with 689 additions and 499 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997 Kungliga Tekniska H<>gskolan
* Copyright (c) 1997, 1998 Kungliga Tekniska H<>gskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -43,6 +43,7 @@ RCSID("$Id$");
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <roken.h>
#include "com_err.h"
struct et_list *_et_list;
@@ -53,8 +54,7 @@ error_message (long code)
static char msg[128];
const char *p = com_right(_et_list, code);
if(p){
strncpy(msg, p, sizeof(msg));
msg[sizeof(msg)-1] = '\0';
strcpy_truncate(msg, p, sizeof(msg));
} else{
snprintf(msg, sizeof(msg), "Unknown error %d", code);
}
@@ -76,18 +76,18 @@ default_proc (const char *whoami, long code, const char *fmt, va_list args)
const void *arg[3], **ap = arg;
if(whoami) {
strcat(f, "%s: ");
strcat_truncate(f, "%s: ", sizeof(f));
*ap++ = whoami;
}
if(code) {
strcat(f, "%s ");
strcat_truncate(f, "%s ", sizeof(f));
*ap++ = error_message(code);
}
if(fmt) {
strcat(f, "%s");
strcat_truncate(f, "%s", sizeof(f));
*ap++ = fmt;
}
strcat(f, "\r\n");
strcat_truncate(f, "\r\n", sizeof(f));
asprintf(&x, f, arg[0], arg[1], arg[2]);
vfprintf(stderr, x, args);
free(x);