[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]
<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.
- [Freeciv-Dev] Re: (PR#13463) New function to eval safety of filenames,
Raimar Falke <=
|
|