rpms/sed/FC-4 sed-4.1.5-relsymlink.patch, NONE, 1.1 sed.spec, 1.29, 1.30
fedora-cvs-commits at redhat.com
fedora-cvs-commits at redhat.com
Mon Sep 4 15:46:05 UTC 2006
Author: pmachata
Update of /cvs/dist/rpms/sed/FC-4
In directory cvs.devel.redhat.com:/tmp/cvs-serv5022
Modified Files:
sed.spec
Added Files:
sed-4.1.5-relsymlink.patch
Log Message:
- Fix handling of relative symlinks (#205122)
sed-4.1.5-relsymlink.patch:
utils.c | 24 +++++++++++++++++++++---
1 files changed, 21 insertions(+), 3 deletions(-)
--- NEW FILE sed-4.1.5-relsymlink.patch ---
diff -burp sed-4.1.5/lib/utils.c sed-4.1.5-pm/lib/utils.c
--- sed-4.1.5/lib/utils.c 2006-09-04 15:57:56.000000000 +0200
+++ sed-4.1.5-pm/lib/utils.c 2006-09-04 17:06:25.000000000 +0200
@@ -322,8 +322,9 @@ do_ck_fclose(fp)
/* Temporary buffer for ck_follow_symlink and ck_fcopy. */
-static char buf[4096];
+static char buf[2048], buf2[2048];
static size_t bufsize = sizeof (buf);
+#include <libgen.h>
/* Follow symlink and panic if something fails. Returned value is
ultimate symlink target, stored in temporary buffer. You need to
@@ -333,6 +334,7 @@ ck_follow_symlink(const char * fname)
{
static struct stat statbuf;
int err;
+ char * dir;
if (strlen (fname) >= bufsize)
panic("ck_follow_symlink: file name too long");
@@ -347,13 +349,29 @@ ck_follow_symlink(const char * fname)
if ((statbuf.st_mode & S_IFLNK) == S_IFLNK)
{
- err = readlink (buf, buf, bufsize);
+ err = readlink (buf, buf2, bufsize);
+
if (err < 0)
panic("ck_follow_symlink: readlink failed on %s: %s", buf, strerror(errno));
else if (err == bufsize)
panic("ck_follow_symlink: pointee name too long");
else
- buf [err] = '\0';
+ buf2 [err] = '\0';
+
+ /* need to handle relative paths with care */
+ if (buf2[0] != '/')
+ {
+ dir = dirname (buf); // dir part of orig path
+ int len = strlen (dir); // orig path len
+ buf[len] = '/';
+ strncpy (buf+len+1, buf2, bufsize - len - 1);
+ if (buf[bufsize-1] != 0)
+ panic("ck_follow_symlink: pointee name too long");
+ }
+ else
+ {
+ strcpy (buf, buf2);
+ }
}
else
break;
Index: sed.spec
===================================================================
RCS file: /cvs/dist/rpms/sed/FC-4/sed.spec,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- sed.spec 3 Aug 2006 13:36:17 -0000 1.29
+++ sed.spec 4 Sep 2006 15:46:02 -0000 1.30
@@ -5,13 +5,14 @@
Summary: A GNU stream text editor.
Name: sed
Version: 4.1.5
-Release: 4.fc4
+Release: 5.fc4
License: GPL
Group: Applications/Text
Source0: ftp://ftp.gnu.org/pub/gnu/sed/sed-%{version}.tar.gz
Source1: http://sed.sourceforge.net/sedfaq.txt
Patch0: sed-4.1.5-utf8performance.patch
Patch1: sed-4.1.5-bz185374.patch
+Patch2: sed-4.1.5-relsymlink.patch
Prereq: /sbin/install-info
Prefix: %{_prefix}
Buildroot: %{_tmppath}/%{name}-root
@@ -29,6 +30,7 @@
%setup -q
%patch0 -p1
%patch1 -p1
+%patch2 -p1
%build
%configure --without-included-regex
@@ -67,6 +69,9 @@
%{_mandir}/man*/*
%changelog
+* Mon Sep 4 2006 Petr Machata <pmachata at redhat.com> - 4.1.5-5.fc4
+- Fix handling of relative symlinks (#205122)
+
* Wed Aug 3 2006 Petr Machata <pmachata at redhat.com> - 4.1.5-4.fc4
- remove superfluous multibyte processing in str_append for UTF-8
encoding (thanks Paolo Bonzini, #177246)
More information about the fedora-cvs-commits
mailing list