From 86ed6de3b2b76c0e2d0c3fa81994a750abd96e83 Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Sun, 10 Sep 1995 13:02:56 +0000 Subject: [PATCH] Fix a bug that prevented %'s and \'s from being passed to the program invoked. Submitted by: fenner@parc.xerox.com (Bill Fenner) --- usr.sbin/cron/cron/do_command.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/usr.sbin/cron/cron/do_command.c b/usr.sbin/cron/cron/do_command.c index f924d3444870..51e6fee9f6fc 100644 --- a/usr.sbin/cron/cron/do_command.c +++ b/usr.sbin/cron/cron/do_command.c @@ -16,7 +16,7 @@ */ #if !defined(lint) && !defined(LINT) -static char rcsid[] = "$Id: do_command.c,v 1.4 1995/04/14 21:54:18 ache Exp $"; +static char rcsid[] = "$Id: do_command.c,v 1.5 1995/05/30 03:47:00 rgrimes Exp $"; #endif @@ -122,13 +122,21 @@ child_process(e, u) * command, and subsequent characters are the additional input to * the command. Subsequent %'s will be transformed into newlines, * but that happens later. + * + * If there are escaped %'s, remove the escape character. */ /*local*/{ register int escaped = FALSE; register int ch; + register char *p; - for (input_data = e->cmd; ch = *input_data; input_data++) { + for (input_data = p = e->cmd; ch = *input_data; + input_data++, p++) { + if (p != input_data) + *p = ch; if (escaped) { + if (ch == '%' || ch == '\\') + *--p = ch; escaped = FALSE; continue; } @@ -141,6 +149,7 @@ child_process(e, u) break; } } + *p = '\0'; } /* fork again, this time so we can exec the user's command.