From 2b54af87e997067a928dd60724acd2467913fde8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Wed, 15 Jul 2009 23:31:55 +0000 Subject: [PATCH] Add paranoid printing using strvisx. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25332 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/krb5/log.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/krb5/log.c b/lib/krb5/log.c index 31d267320..ee5c1159b 100644 --- a/lib/krb5/log.c +++ b/lib/krb5/log.c @@ -32,6 +32,7 @@ */ #include "krb5_locl.h" +#include struct facility { int min; @@ -218,11 +219,21 @@ log_file(const char *timestr, void *data) { struct file_data *f = data; + char *msgclean; + size_t len = strlen(msg) + 1; if(f->keep_open == 0) f->fd = fopen(f->filename, f->mode); if(f->fd == NULL) return; - fprintf(f->fd, "%s %s\n", timestr, msg); + /* make sure the log doesn't contain special chars */ + len *= 4; + msgclean = malloc(len); + if (msgclean == NULL) + goto out; + strvisx(rk_UNCONST(msg), msgclean, len, VIS_OCTAL); + fprintf(f->fd, "%s %s\n", timestr, msgclean); + free(msgclean); + out: if(f->keep_open == 0) { fclose(f->fd); f->fd = NULL;