Fix tame(2) for patch(1). To recreate:

/usr/src/regress/usr.bin/diff$ cat t2.1
Below is an example license to be used for new code in OpenBSD,
modeled after the ISC license.

It is important to specify the year of the copyright.  Additional years
should be separated by a comma, e.g.
    Copyright (c) 2003, 2004

If you add extra text to the body of the license, be careful not to
add further restrictions.

/*
 * Copyright (c) CCYY YOUR NAME HERE <[email protected]>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */
/usr/src/regress/usr.bin/diff$ cat t2.e.patch
25a
An extra line
.
14d
6c
    Copyright (c) 2003, 2004, 2005
.
/usr/src/regress/usr.bin/diff$ patch -sb t2.1 t2.e.patch        
zsh: killed     patch -sb t2.1 t2.e.patch



Fixed by adding "proc" to the list of valid tame(2) requests. I'm not
happy with this patch -- not sure if I'm just not happy with patch.c, or
if I'm concerned about the `for' loop.

***

Index: patch.c
===================================================================
RCS file: /cvs/src/usr.bin/patch/patch.c,v
retrieving revision 1.55
diff -u -p -r1.55 patch.c
--- patch.c     3 Oct 2015 02:35:56 -0000       1.55
+++ patch.c     3 Oct 2015 20:43:25 -0000
@@ -147,7 +147,7 @@ main(int argc, char *argv[])
        const   char *tmpdir;
        char    *v;
 
-       if (tame("stdio rpath wpath cpath tmppath fattr", NULL) == -1)
+       if (tame("stdio rpath wpath cpath tmppath fattr proc", NULL) == -1)
                perror("tame");
 
        setvbuf(stdout, NULL, _IOLBF, 0);
@@ -223,6 +223,10 @@ main(int argc, char *argv[])
                        do_ed_script();
                        continue;
                }
+
+               if (tame("stdio rpath wpath cpath tmppath fattr", NULL) == -1)
+                       perror("tame");
+
                /* initialize the patched file */
                if (!skip_rest_of_patch)
                        init_output(TMPOUTNAME);

Reply via email to