diff options
Diffstat (limited to 'contrib/texinfo/info/filesys.c')
-rw-r--r-- | contrib/texinfo/info/filesys.c | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/contrib/texinfo/info/filesys.c b/contrib/texinfo/info/filesys.c index 96f0ed9..cdf1365 100644 --- a/contrib/texinfo/info/filesys.c +++ b/contrib/texinfo/info/filesys.c @@ -1,7 +1,7 @@ /* filesys.c -- filesystem specific functions. - $Id: filesys.c,v 1.10 1998/12/06 21:58:30 karl Exp $ + $Id: filesys.c,v 1.14 2002/03/02 15:05:04 karl Exp $ - Copyright (C) 1993, 97, 98 Free Software Foundation, Inc. + Copyright (C) 1993, 97, 98, 2000 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -163,6 +163,11 @@ info_file_in_path (filename, path) char *temp_dirname; int statable, dirname_index; + /* Reject ridiculous cases up front, to prevent infinite recursion + later on. E.g., someone might say "info '(.)foo'"... */ + if (!*filename || STREQ (filename, ".") || STREQ (filename, "..")) + return NULL; + dirname_index = 0; while ((temp_dirname = extract_colon_unit (path, &dirname_index))) @@ -557,7 +562,7 @@ filesys_read_compressed (pathname, filesize, finfo) /* Read chunks from this file until there are none left to read. */ if (stream) { - int offset, size; + long offset, size; char *chunk; offset = size = 0; @@ -689,25 +694,34 @@ filesys_error_string (filename, error_num) } -/* Check for FILENAME eq "dir" first, then all the compression - suffixes. */ +/* Check for "dir" with all the possible info and compression suffixes, + in combination. */ int is_dir_name (filename) char *filename; { unsigned i; - if (strcasecmp (filename, "dir") == 0) - return 1; - - for (i = 0; compress_suffixes[i].suffix; i++) + + for (i = 0; info_suffixes[i]; i++) { - char dir_compressed[50]; /* can be short */ - strcpy (dir_compressed, "dir"); - strcat (dir_compressed, compress_suffixes[i].suffix); - if (strcasecmp (filename, dir_compressed) == 0) + unsigned c; + char trydir[50]; + strcpy (trydir, "dir"); + strcat (trydir, info_suffixes[i]); + + if (strcasecmp (filename, trydir) == 0) return 1; - } - + + for (c = 0; compress_suffixes[c].suffix; c++) + { + char dir_compressed[50]; /* can be short */ + strcpy (dir_compressed, trydir); + strcat (dir_compressed, compress_suffixes[c].suffix); + if (strcasecmp (filename, dir_compressed) == 0) + return 1; + } + } + return 0; } |