[Top][All Lists]
[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: |
Thu, 17 Feb 2011 09:25:57 +0100 |
Andreas Gruenbacher wrote:
> On Wednesday 16 February 2011 18:03:21 Jim Meyering wrote:
>> Here's a better patch.
>
> Nice. Now we can suppress warnings for equal filenames too for even fewer
> confusing warnings. Here is your last patch + some coding style changes +
> actually comparing filenames + test case.
Good improvements. I usually put a space between the "!!" operator
and its operand, too.
I noticed that we can avoid a useless comparison in the common case,
(i.e., if bad[0] is NULL, there's no point in testing bad[1])
but am not sure it's worth the addition of three lines and loss
of symmetry:
if (bad[0])
{
if (! strcmp (bad[0], name))
return false;
if (bad[1] && ! strcmp (bad[1], name))
return false;
}
> diff --git a/src/pch.c b/src/pch.c
> index 41c15b6..1fd3848 100644
> --- a/src/pch.c
> +++ b/src/pch.c
> @@ -379,11 +379,18 @@ skip_hex_digits (char const *str)
> static bool
> name_is_valid (char const *name)
> {
> - const char *n = name;
> + static char const *bad[2];
> + char const *n;
> +
> + if (bad[0] && ! strcmp (bad[0], name))
> + return false;
> + if (bad[1] && ! strcmp (bad[1], name))
> + return false;
>
> if (IS_ABSOLUTE_FILE_NAME (name))
> {
> say ("Ignoring potentially dangerous file name %s\n", quotearg (name));
> + bad[!! bad[0]] = name;
> return false;
> }
> for (n = name; *n; )
> @@ -391,6 +398,7 @@ name_is_valid (char const *name)
> if (*n == '.' && *++n == '.' && ( ! *++n || ISSLASH (*n)))
> {
> say ("Ignoring potentially dangerous file name %s\n", quotearg
> (name));
> + bad[!! bad[0]] = name;
> return false;
> }
> while (*n && ! ISSLASH (*n))
- Re: [bug-patch] [PATCH] do not validate target name when it is specified on the command line, (continued)
- Re: [bug-patch] [PATCH] do not validate target name when it is specified on the command line, Jim Meyering, 2011/02/16
- Re: [bug-patch] [PATCH] do not validate target name when it is specified on the command line, Andreas Gruenbacher, 2011/02/16
- Re: [bug-patch] [PATCH] do not validate target name when it is specified on the command line, Jim Meyering, 2011/02/16
- Re: [bug-patch] [PATCH] do not validate target name when it is specified on the command line, Andreas Gruenbacher, 2011/02/16
- Re: [bug-patch] [PATCH] do not validate target name when it is specified on the command line, Jim Meyering, 2011/02/16
- Re: [bug-patch] [PATCH] do not validate target name when it is specified on the command line, Andreas Gruenbacher, 2011/02/16
- Re: [bug-patch] [PATCH] do not validate target name when it is specified on the command line, Jim Meyering, 2011/02/16
- Re: [bug-patch] [PATCH] do not validate target name when it is specified on the command line, Andreas Gruenbacher, 2011/02/17
- Re: [bug-patch] [PATCH] do not validate target name when it is specified on the command line,
Jim Meyering <=
- Re: [bug-patch] [PATCH] do not validate target name when it is specified on the command line, Andreas Gruenbacher, 2011/02/17
- Re: [bug-patch] [PATCH] do not validate target name when it is specified on the command line, Jim Meyering, 2011/02/17