Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/cron Fix a bug that prevented %'s and \'s from bein...



details:   https://anonhg.NetBSD.org/src/rev/9acdba2d43a9
branches:  trunk
changeset: 513539:9acdba2d43a9
user:      yamt <yamt%NetBSD.org@localhost>
date:      Fri Aug 03 04:10:51 2001 +0000

description:
Fix a bug that prevented %'s and \'s from being passed to the program
invoked.
from FreeBSD.

diffstat:

 usr.sbin/cron/do_command.c |  18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)

diffs (55 lines):

diff -r 51f9bc4ca0bd -r 9acdba2d43a9 usr.sbin/cron/do_command.c
--- a/usr.sbin/cron/do_command.c        Fri Aug 03 02:30:23 2001 +0000
+++ b/usr.sbin/cron/do_command.c        Fri Aug 03 04:10:51 2001 +0000
@@ -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 @@
         * 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 @@
                                continue;
                        }
                        if (ch == '%') {
-                               *input_data++ = '\0';
+                               input_data++;
                                break;
                        }
                }
+               *p = '\0';
        }
 
        /* fork again, this time so we can exec the user's command.



Home | Main Index | Thread Index | Old Index