format checking for internal functions

This commit is contained in:
sommerfeld 2000-10-05 14:17:12 +00:00
parent 29dec280ee
commit 37146bcc18
3 changed files with 33 additions and 20 deletions

View File

@ -33,8 +33,11 @@
#include <krb5_locl.h>
RCSID("$Id: changepw.c,v 1.1.1.2 2000/08/02 19:59:24 assar Exp $");
RCSID("$Id: changepw.c,v 1.2 2000/10/05 14:17:12 sommerfeld Exp $");
static void str2data (krb5_data *d, char *fmt, ...)
__attribute__((__format__(__printf__, 2, 3)));
static krb5_error_code
get_kdc_address (krb5_context context,
krb5_realm realm,

View File

@ -34,43 +34,47 @@
#include "krb5_locl.h"
#include <err.h>
RCSID("$Id: warn.c,v 1.1.1.2 2000/08/02 19:59:44 assar Exp $");
RCSID("$Id: warn.c,v 1.2 2000/10/05 14:17:12 sommerfeld Exp $");
static krb5_error_code _warnerr(krb5_context context, int do_errtext,
krb5_error_code code, int level, const char *fmt, va_list ap)
__attribute__((__format__(__printf__, 5, 0)));
static krb5_error_code
_warnerr(krb5_context context, int do_errtext,
krb5_error_code code, int level, const char *fmt, va_list ap)
{
char xfmt[7] = "";
const char *args[2], **arg;
char *msg = NULL;
arg = args;
if(fmt){
strcat(xfmt, "%s");
if(do_errtext)
strcat(xfmt, ": ");
vasprintf(&msg, fmt, ap);
if(msg == NULL)
return ENOMEM;
*arg++ = msg;
}
if(context && do_errtext){
const char *err_msg;
strcat(xfmt, "%s");
err_msg = krb5_get_err_text(context, code);
if (err_msg)
*arg++ = err_msg;
else
*arg++ = "<unknown error>";
if (!err_msg)
err_msg = "<unknown error>";
if (msg) {
char *nmsg = NULL;
asprintf(&nmsg, "%s: %s", msg, err_msg);
free(msg);
if (nmsg == NULL)
return ENOMEM;
msg = nmsg;
}
}
if(context && context->warn_dest)
krb5_log(context, context->warn_dest, level, xfmt, args[0], args[1]);
krb5_log(context, context->warn_dest, level, "%s", msg ? msg : "");
else
warnx(xfmt, args[0], args[1]);
free(msg);
warnx("%s", msg ? msg : "");
if (msg)
free(msg);
return 0;
}

View File

@ -34,7 +34,7 @@
#include "krb_locl.h"
#include <klog.h>
RCSID("$Id: logging.c,v 1.1.1.1 2000/06/16 18:45:54 thorpej Exp $");
RCSID("$Id: logging.c,v 1.2 2000/10/05 14:22:24 sommerfeld Exp $");
struct krb_log_facility {
char filename[MaxPathLen];
@ -42,6 +42,12 @@ struct krb_log_facility {
krb_log_func_t func;
};
static int log_tty(FILE *, const char *, va_list)
__attribute__((__format__(__printf__, 2, 0)));
static int
log_with_timestamp_and_nl(FILE *file, const char *format, va_list args)
__attribute__((__format__(__printf__, 2, 0)));
int
krb_vlogger(struct krb_log_facility *f, const char *format, va_list args)
{
@ -91,7 +97,7 @@ krb_openlog(struct krb_log_facility *f,
/* ------------------------------------------------------------
Compatibility functions from warning.c
------------------------------------------------------------ */
static int
log_tty(FILE *f, const char *format, va_list args)
{