From 51fbbf93e3842581b6fcf94e84a76be7e2ccc398 Mon Sep 17 00:00:00 2001 From: Love Hornquist Astrand Date: Sun, 19 Jul 2009 17:52:53 -0700 Subject: [PATCH] (log_file): use strvisx rightly --- lib/krb5/log.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/krb5/log.c b/lib/krb5/log.c index ee5c1159b..5b84bc2f4 100644 --- a/lib/krb5/log.c +++ b/lib/krb5/log.c @@ -220,17 +220,16 @@ log_file(const char *timestr, { struct file_data *f = data; char *msgclean; - size_t len = strlen(msg) + 1; + size_t len = strlen(msg); if(f->keep_open == 0) f->fd = fopen(f->filename, f->mode); if(f->fd == NULL) return; /* make sure the log doesn't contain special chars */ - len *= 4; - msgclean = malloc(len); + msgclean = malloc((len + 1) * 4); if (msgclean == NULL) goto out; - strvisx(rk_UNCONST(msg), msgclean, len, VIS_OCTAL); + strvisx(msgclean, rk_UNCONST(msg), len, VIS_OCTAL); fprintf(f->fd, "%s %s\n", timestr, msgclean); free(msgclean); out: