Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2005:
[Freeciv-Dev] Re: (PR#13463) New function to eval safety of filenames
Home

[Freeciv-Dev] Re: (PR#13463) New function to eval safety of filenames

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: per@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#13463) New function to eval safety of filenames
From: "Raimar Falke" <i-freeciv-lists@xxxxxxxxxxxxx>
Date: Tue, 12 Jul 2005 14:06:30 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13463 >

On Tue, Jul 12, 2005 at 01:50:58PM -0700, Per I. Mathisen wrote:
> +  /* must begin and end with some non-space character */
> +  if ((*name == ' ') || (*(strchr(name, '\0') - 1) == ' ')) {
> +    return FALSE;
> +  }

What is the point if we forbid spaces anyway below?

> +  /* Accept only alphanumerics and -._ */
> +  for (i = 0; name[i]; i++) {
> +    if (!((name[i] <= 'z' && name[i] >= 'a')
> +          || (name[i] <= 'Z' && name[i] >= 'A')
> +          || (name[i] <= '9' && name[i] >= '0')
> +          || name[i] == '.'
> +          || name[i] == '-'
> +          || name[i] == '_')) {
> +      return FALSE;
> +    }
> +  }
> +
> +  /* Otherwise, it is okay... */
> +  return TRUE;
> +}

Alternative would be something like:

  if(strchr(".-_0123456789abc...zABC...Z", name[i])==NULL) {return FALSE;}

        Raimar

-- 
 email: i-freeciv-lists@xxxxxxxxxxxxx
  Living on earth may be expensive, but it includes an annual free trip
  around the sun.





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