apply new hurd patch to my tree master
authorBdale Garbee <bdale@gag.com>
Tue, 1 Nov 2011 13:00:18 +0000 (07:00 -0600)
committerBdale Garbee <bdale@gag.com>
Tue, 1 Nov 2011 13:00:18 +0000 (07:00 -0600)
file_subs.c
tables.c

index 4191b92969a9787a0ff4102b00e692b224b8b1d4..e32f7ef450295e82618b4fea2271eeba6f3772e4 100644 (file)
@@ -382,7 +382,7 @@ node_creat(ARCHD *arcn)
                                                return(-1);
                                        }
                                        len = readlink(nm, target,
-                                           sb.st_size);
+                                           sb.st_size + 1);
                                        if (len == -1) {
                                                syswarn(0, errno,
                                                   "cannot follow symlink %s in chain for %s",
@@ -390,6 +390,14 @@ node_creat(ARCHD *arcn)
                                                res = -1;
                                                goto badlink;
                                        }
+                                       if (len > sb.st_size) {
+                                               syswarn(0, errno,
+                                                  "symlink %s increased in size between lstat() and readlink() for %s",
+                                                   nm, arcn->name);
+
+                                               res = -1;
+                                               goto badlink;
+                                       }
                                        target[len] = '\0';
                                        nm = target;
                                }
index 0e75ea51e69579c2bf744e1df9cccd0a1c38bed5..9543a90990cb49403d976016bfc59d3e5035ba9c 100644 (file)
--- a/tables.c
+++ b/tables.c
@@ -55,7 +55,7 @@ static const char rcsid[] = "$OpenBSD: tables.c,v 1.25 2007/09/02 15:19:08 deraa
 #include "pax.h"
 #include "tables.h"
 #include "extern.h"
-#include "features.h"
+#include <unistd.h>
 
 /*
  * Routines for controlling the contents of all the different databases pax
@@ -1127,7 +1127,7 @@ void
 add_dir(char *name, struct stat *psb, int frc_mode)
 {
        DIRDATA *dblk;
-#if (_POSIX_C_SOURCE - 0) >= 200809L
+#if (_POSIX_VERSION >= 200809L)
        char *rp = NULL;
 #else
        char realname[MAXPATHLEN], *rp;
@@ -1137,7 +1137,7 @@ add_dir(char *name, struct stat *psb, int frc_mode)
                return;
 
        if (havechd && *name != '/') {
-#if (_POSIX_C_SOURCE - 0) >= 200809L
+#if (_POSIX_VERSION >= 200809L)
                if ((rp = realpath(name, NULL)) == NULL) {
 #else
                if ((rp = realpath(name, realname)) == NULL) {
@@ -1152,7 +1152,7 @@ add_dir(char *name, struct stat *psb, int frc_mode)
                if (dblk == NULL) {
                        paxwarn(1, "Unable to store mode and times for created"
                            " directory: %s", name);
-#if (_POSIX_C_SOURCE - 0) >= 200809L
+#if (_POSIX_VERSION >= 200809L)
                        free(rp);
 #endif
                        return;
@@ -1164,7 +1164,7 @@ add_dir(char *name, struct stat *psb, int frc_mode)
        if ((dblk->name = strdup(name)) == NULL) {
                paxwarn(1, "Unable to store mode and times for created"
                    " directory: %s", name);
-#if (_POSIX_C_SOURCE - 0) >= 200809L
+#if (_POSIX_VERSION >= 200809L)
                free(rp);
 #endif
                return;
@@ -1174,7 +1174,7 @@ add_dir(char *name, struct stat *psb, int frc_mode)
        dblk->atime = psb->st_atime;
        dblk->frc_mode = frc_mode;
        ++dircnt;
-#if (_POSIX_C_SOURCE - 0) >= 200809L
+#if (_POSIX_VERSION >= 200809L)
        free(rp);
 #endif
 }