diff options
author | wlemb <wlemb> | 2000-11-13 16:51:26 +0000 |
---|---|---|
committer | wlemb <wlemb> | 2000-11-13 16:51:26 +0000 |
commit | b4daf3b0fd8f8efd95141f6375003e26b822da36 (patch) | |
tree | 9310440a358a56eb9a73662e730fcb434ab5fe06 /src/libs/libgroff | |
parent | 9ab09435852a552b6ea5acb3879d398c743ea44e (diff) | |
download | groff-b4daf3b0fd8f8efd95141f6375003e26b822da36.tar.gz |
For security reasons, don't use the current directory but the home
directory while searching and scanning troffrc and troffrc-end.
Similarly, replace the current directory with the home directory
in the font path.
* Makefile.in (fontpath, tmacpath): Remove current directory.
* src/libs/libgroff/searchpath.cc (search_path::search_path): Add
two parameters `add_home' and `add_current'.
(search_path::~search_path, search_path::command_line_dir,
search_path::open_file): Remove tests for `dirs' being zero.
* src/include/searchpath.h: Adjust.
* src/libs/libgroff/macropath.cc, src/include/macropath.h: Add
`safer_macro_path'.
* src/libs/libgroff/fontfile.cc: Adjust `font_path'.
* src/roff/troff/troff.h: Add `searchpath.h' and `mac_path'.
* src/roff/troff/input.cc: Use `mac_path', initialized with
`macro_path'.
(process_startup_file): Set `mac_path' to `safer_macro_path'.
* src/roff/troff/env.cc: Use `mac_path'.
* src/preproc/eqn/main.cc (main): Use `safer_macro_path'.
* NEWS, man/roff.man, src/roff/troff/troff.man,
src/rof/groff/groff.man, tmac/groff_tmac.man, arch/djgpp/README:
Updated.
* src/include/lib.h: Don't include groff-getopt.h for OSF/1.
* aclocal.m4 (GROFF_SYS_ERRLIST): Do test in C, not in C++.
* configure.in: Fix typo in comment.
* configure: Regenerated.
* src/libgroff/*, src/include/*, src/roff/troff/*: Fixing copyright
dates.
Diffstat (limited to 'src/libs/libgroff')
-rw-r--r-- | src/libs/libgroff/errarg.cc | 2 | ||||
-rw-r--r-- | src/libs/libgroff/font.cc | 2 | ||||
-rw-r--r-- | src/libs/libgroff/fontfile.cc | 2 | ||||
-rw-r--r-- | src/libs/libgroff/getcwd.c | 19 | ||||
-rwxr-xr-x | src/libs/libgroff/htmlindicate.cc | 2 | ||||
-rw-r--r-- | src/libs/libgroff/iftoa.c | 2 | ||||
-rwxr-xr-x | src/libs/libgroff/illegal.cc | 19 | ||||
-rw-r--r-- | src/libs/libgroff/itoa.c | 2 | ||||
-rw-r--r-- | src/libs/libgroff/macropath.cc | 5 | ||||
-rw-r--r-- | src/libs/libgroff/nametoindex.cc | 2 | ||||
-rw-r--r-- | src/libs/libgroff/searchpath.cc | 82 | ||||
-rw-r--r-- | src/libs/libgroff/strtol.c | 2 | ||||
-rw-r--r-- | src/libs/libgroff/tmpfile.cc | 2 |
13 files changed, 98 insertions, 45 deletions
diff --git a/src/libs/libgroff/errarg.cc b/src/libs/libgroff/errarg.cc index be4d3dc9..f8075ea7 100644 --- a/src/libs/libgroff/errarg.cc +++ b/src/libs/libgroff/errarg.cc @@ -1,5 +1,5 @@ // -*- C++ -*- -/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc. +/* Copyright (C) 1989, 1990, 1991, 1992, 2000 Free Software Foundation, Inc. Written by James Clark (jjc@jclark.com) This file is part of groff. diff --git a/src/libs/libgroff/font.cc b/src/libs/libgroff/font.cc index c3bfa23e..8e1b97dc 100644 --- a/src/libs/libgroff/font.cc +++ b/src/libs/libgroff/font.cc @@ -1,5 +1,5 @@ // -*- C++ -*- -/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc. +/* Copyright (C) 1989, 1990, 1991, 1992, 2000 Free Software Foundation, Inc. Written by James Clark (jjc@jclark.com) This file is part of groff. diff --git a/src/libs/libgroff/fontfile.cc b/src/libs/libgroff/fontfile.cc index fa87b861..5846a8dc 100644 --- a/src/libs/libgroff/fontfile.cc +++ b/src/libs/libgroff/fontfile.cc @@ -31,7 +31,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ const char *const FONT_ENV_VAR = "GROFF_FONT_PATH"; -static search_path font_path(FONT_ENV_VAR, FONTPATH); +static search_path font_path(FONT_ENV_VAR, FONTPATH, 1, 0); int font::res = 0; int font::hor = 1; diff --git a/src/libs/libgroff/getcwd.c b/src/libs/libgroff/getcwd.c index ed1642fe..7a769ffc 100644 --- a/src/libs/libgroff/getcwd.c +++ b/src/libs/libgroff/getcwd.c @@ -1,3 +1,22 @@ +/* Copyright (C) 2000 Free Software Foundation, Inc. + Written by James Clark (jjc@jclark.com) + +This file is part of groff. + +groff is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +groff is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License along +with groff; see the file COPYING. If not, write to the Free Software +Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + /* Partial emulation of getcwd in terms of getwd. */ #include <sys/param.h> diff --git a/src/libs/libgroff/htmlindicate.cc b/src/libs/libgroff/htmlindicate.cc index 1ebfb769..6b5913f3 100755 --- a/src/libs/libgroff/htmlindicate.cc +++ b/src/libs/libgroff/htmlindicate.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc. +/* Copyright (C) 2000 Free Software Foundation, Inc. Written by Gaius Mulley (gaius@glam.ac.uk) This file is part of groff. diff --git a/src/libs/libgroff/iftoa.c b/src/libs/libgroff/iftoa.c index fa108337..29a3d894 100644 --- a/src/libs/libgroff/iftoa.c +++ b/src/libs/libgroff/iftoa.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc. +/* Copyright (C) 1989, 1990, 1991, 1992, 2000 Free Software Foundation, Inc. Written by James Clark (jjc@jclark.com) This file is part of groff. diff --git a/src/libs/libgroff/illegal.cc b/src/libs/libgroff/illegal.cc index c1bdbc50..bacd891f 100755 --- a/src/libs/libgroff/illegal.cc +++ b/src/libs/libgroff/illegal.cc @@ -1,3 +1,22 @@ +/* Copyright (C) 2000 Free Software Foundation, Inc. + Written by James Clark (jjc@jclark.com) + +This file is part of groff. + +groff is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +groff is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License along +with groff; see the file COPYING. If not, write to the Free Software +Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + #include "lib.h" // Table of illegal input characters. diff --git a/src/libs/libgroff/itoa.c b/src/libs/libgroff/itoa.c index c811c765..72826b74 100644 --- a/src/libs/libgroff/itoa.c +++ b/src/libs/libgroff/itoa.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc. +/* Copyright (C) 1989, 1990, 1991, 1992, 2000 Free Software Foundation, Inc. Written by James Clark (jjc@jclark.com) This file is part of groff. diff --git a/src/libs/libgroff/macropath.cc b/src/libs/libgroff/macropath.cc index 4fd22a30..3a11bdfa 100644 --- a/src/libs/libgroff/macropath.cc +++ b/src/libs/libgroff/macropath.cc @@ -1,5 +1,5 @@ // -*- C++ -*- -/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc. +/* Copyright (C) 1989, 1990, 1991, 1992, 2000 Free Software Foundation, Inc. Written by James Clark (jjc@jclark.com) This file is part of groff. @@ -25,4 +25,5 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define MACROPATH_ENVVAR "GROFF_TMAC_PATH" -search_path macro_path(MACROPATH_ENVVAR, MACROPATH); +search_path macro_path(MACROPATH_ENVVAR, MACROPATH, 0, 1); +search_path safer_macro_path(MACROPATH_ENVVAR, MACROPATH, 1, 0); diff --git a/src/libs/libgroff/nametoindex.cc b/src/libs/libgroff/nametoindex.cc index 39a7b697..578ff349 100644 --- a/src/libs/libgroff/nametoindex.cc +++ b/src/libs/libgroff/nametoindex.cc @@ -1,5 +1,5 @@ // -*- C++ -*- -/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc. +/* Copyright (C) 1989, 1990, 1991, 1992, 2000 Free Software Foundation, Inc. Written by James Clark (jjc@jclark.com) This file is part of groff. diff --git a/src/libs/libgroff/searchpath.cc b/src/libs/libgroff/searchpath.cc index a857c258..f4e2b90d 100644 --- a/src/libs/libgroff/searchpath.cc +++ b/src/libs/libgroff/searchpath.cc @@ -1,5 +1,5 @@ // -*- C++ -*- -/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc. +/* Copyright (C) 1989, 1990, 1991, 1992, 2000 Free Software Foundation, Inc. Written by James Clark (jjc@jclark.com) This file is part of groff. @@ -27,56 +27,70 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "searchpath.h" #include "nonposix.h" -search_path::search_path(const char *envvar, const char *standard) +search_path::search_path(const char *envvar, const char *standard, + int add_home, int add_current) { - char *e = envvar ? getenv(envvar) : 0; - if (e && standard) { - dirs = new char[strlen(e) + strlen(standard) + 2]; - strcpy(dirs, e); + char *home = 0; + if (add_home) + home = getenv("HOME"); + char *e = 0; + if (envvar) + e = getenv(envvar); + dirs = new char[((e && *e) ? strlen(e) + 1 : 0) + + (add_current ? 1 + 1 : 0) + + ((home && *home) ? strlen(home) + 1 : 0) + + ((standard && *standard) ? strlen(standard) : 0) + + 1]; + *dirs = '\0'; + if (e && *e) { + strcat(dirs, e); + strcat(dirs, PATH_SEP); + } + if (add_current) { + strcat(dirs, "."); + strcat(dirs, PATH_SEP); + } + if (home && *home) { + strcat(dirs, home); strcat(dirs, PATH_SEP); - strcat(dirs, standard); } - else - dirs = strsave(e ? e : standard); - init_len = dirs ? strlen(dirs) : 0; + if (standard && *standard) + strcat(dirs, standard); + init_len = strlen(dirs); } search_path::~search_path() { - if (dirs) - a_delete dirs; + // dirs is always allocated + a_delete dirs; } void search_path::command_line_dir(const char *s) { - if (!dirs) - dirs = strsave(s); - else { - char *old = dirs; - unsigned old_len = strlen(old); - unsigned slen = strlen(s); - dirs = new char[old_len + 1 + slen + 1]; - memcpy(dirs, old, old_len - init_len); - char *p = dirs; - p += old_len - init_len; - if (init_len == 0) - *p++ = PATH_SEP[0]; - memcpy(p, s, slen); - p += slen; - if (init_len > 0) { - *p++ = PATH_SEP[0]; - memcpy(p, old + old_len - init_len, init_len); - p += init_len; - } - *p++ = '\0'; - a_delete old; + char *old = dirs; + unsigned old_len = strlen(old); + unsigned slen = strlen(s); + dirs = new char[old_len + 1 + slen + 1]; + memcpy(dirs, old, old_len - init_len); + char *p = dirs; + p += old_len - init_len; + if (init_len == 0) + *p++ = PATH_SEP[0]; + memcpy(p, s, slen); + p += slen; + if (init_len > 0) { + *p++ = PATH_SEP[0]; + memcpy(p, old + old_len - init_len, init_len); + p += init_len; } + *p++ = '\0'; + a_delete old; } FILE *search_path::open_file(const char *name, char **pathp) { assert(name != 0); - if (IS_ABSOLUTE(name) || dirs == 0 || *dirs == '\0') { + if (IS_ABSOLUTE(name) || *dirs == '\0') { FILE *fp = fopen(name, "r"); if (fp) { if (pathp) diff --git a/src/libs/libgroff/strtol.c b/src/libs/libgroff/strtol.c index 7858ba5c..61ce70e9 100644 --- a/src/libs/libgroff/strtol.c +++ b/src/libs/libgroff/strtol.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc. +/* Copyright (C) 1989, 1990, 1991, 1992, 2000 Free Software Foundation, Inc. Written by James Clark (jjc@jclark.com) This file is part of groff. diff --git a/src/libs/libgroff/tmpfile.cc b/src/libs/libgroff/tmpfile.cc index c839f7e0..cb192e38 100644 --- a/src/libs/libgroff/tmpfile.cc +++ b/src/libs/libgroff/tmpfile.cc @@ -1,5 +1,5 @@ // -*- C++ -*- -/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc. +/* Copyright (C) 1989, 1990, 1991, 1992, 2000 Free Software Foundation, Inc. Written by James Clark (jjc@jclark.com) This file is part of groff. |