From 69ecbbeb805425129effad4e38295e9bca62a8e7 Mon Sep 17 00:00:00 2001 From: yamt Date: Fri, 3 Aug 2001 04:10:51 +0000 Subject: [PATCH] Fix a bug that prevented %'s and \'s from being passed to the program invoked. from FreeBSD. --- usr.sbin/cron/do_command.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/usr.sbin/cron/do_command.c b/usr.sbin/cron/do_command.c index a850f2e087a1..43e492db2658 100644 --- a/usr.sbin/cron/do_command.c +++ b/usr.sbin/cron/do_command.c @@ -1,4 +1,4 @@ -/* $NetBSD: do_command.c,v 1.7 2001/03/13 17:51:50 wiz Exp $ */ +/* $NetBSD: do_command.c,v 1.8 2001/08/03 04:10:51 yamt Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -22,7 +22,7 @@ #if 0 static char rcsid[] = "Id: do_command.c,v 2.12 1994/01/15 20:43:43 vixie Exp "; #else -__RCSID("$NetBSD: do_command.c,v 1.7 2001/03/13 17:51:50 wiz Exp $"); +__RCSID("$NetBSD: do_command.c,v 1.8 2001/08/03 04:10:51 yamt Exp $"); #endif #endif @@ -133,14 +133,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*/{ int escaped = FALSE; int ch; + char *p; - for (input_data = e->cmd; (ch = *input_data) != '\0'; - input_data++) { + for (input_data = p = e->cmd; (ch = *input_data) != '\0'; + input_data++, p++) { + if (p != input_data) + *p = ch; if (escaped) { + if (ch == '%' || ch == '\\') + *--p = ch; escaped = FALSE; continue; } @@ -149,10 +156,11 @@ child_process(e, u) continue; } if (ch == '%') { - *input_data++ = '\0'; + input_data++; break; } } + *p = '\0'; } /* fork again, this time so we can exec the user's command.