bug-patch
[Top][All Lists]
Advanced

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

Re: [bug-patch] [PATCH] do not validate target name when it is specified


From: Jim Meyering
Subject: Re: [bug-patch] [PATCH] do not validate target name when it is specified on the command line
Date: Wed, 16 Feb 2011 16:24:41 +0100

Andreas Gruenbacher wrote:

> On Wednesday 16 February 2011 15:27:42 Jim Meyering wrote:
>> Patch still stats the offending file.
>
> That would be tricky to avoid while at the same time not warning about file
> names that patch is not going to use anyway.  I don't think it can do any
> harm.
>
>> [...] if you create ../z, then it will print the new "Ignoring ..."
>> diagnostic twice.
>
> That's ugly, and I did not run into this case before.
> Here's a possible fix.

Here's a less invasive option:

diff --git a/src/pch.c b/src/pch.c
index 41c15b6..33c61ad 100644
--- a/src/pch.c
+++ b/src/pch.c
@@ -380,10 +380,15 @@ static bool
 name_is_valid (char const *name)
 {
   const char *n = name;
+  static char const *bad;
+
+  if (name == bad)
+    return false;

   if (IS_ABSOLUTE_FILE_NAME (name))
     {
       say ("Ignoring potentially dangerous file name %s\n", quotearg (name));
+      bad = name;
       return false;
     }
   for (n = name; *n; )
@@ -391,6 +396,7 @@ name_is_valid (char const *name)
       if (*n == '.' && *++n == '.' && ( ! *++n || ISSLASH (*n)))
         {
          say ("Ignoring potentially dangerous file name %s\n", quotearg 
(name));
+         bad = name;
          return false;
        }
       while (*n && ! ISSLASH (*n))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]