From 7ce16230e78e39d755acc3ce15d523ac54f617d9 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 3 Jun 2002 02:09:21 +0000 Subject: Shrouding fix. svn path=/trunk/; revision=3623 --- transact.c | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-) (limited to 'transact.c') diff --git a/transact.c b/transact.c index 0d219ad0..4750fbee 100644 --- a/transact.c +++ b/transact.c @@ -1333,6 +1333,23 @@ void init_transact(const struct method *proto) protocol = (struct method *)proto; } +static void enshroud(char *buf) +/* shroud a password in the given buffer */ +{ + char *cp; + + if (shroud[0] && (cp = strstr(buf, shroud))) + { + char *sp; + + sp = cp + strlen(shroud); + *cp = '*'; + while (*sp) + *cp++ = *sp++; + *cp = '\0'; + } +} + #if defined(HAVE_STDARG_H) void gen_send(int sock, const char *fmt, ... ) #else @@ -1372,18 +1389,7 @@ va_dcl if (outlevel >= O_MONITOR) { - char *cp; - - if (shroud[0] && (cp = strstr(buf, shroud))) - { - char *sp; - - sp = cp + strlen(shroud); - *cp++ = '*'; - while (*sp) - *cp++ = *sp++; - *cp = '\0'; - } + enshroud(buf); buf[strlen(buf)-2] = '\0'; report(stdout, "%s> %s\n", protocol->name, buf); } @@ -1462,19 +1468,8 @@ va_dcl if (outlevel >= O_MONITOR) { - char *cp; - - if (shroud && shroud[0] && (cp = strstr(buf, shroud))) - { - char *sp; - - sp = cp + strlen(shroud); - *cp++ = '*'; - while (*sp) - *cp++ = *sp++; - *cp = '\0'; - } - buf[strlen(buf)-1] = '\0'; + enshroud(buf); + buf[strlen(buf)-2] = '\0'; report(stdout, "%s> %s\n", protocol->name, buf); } -- cgit v1.2.3