From 8e72924eb66c7421bf2eb68f5f54a2ed68bc5f00 Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Thu, 24 Sep 2009 17:53:01 +0000 Subject: [PATCH] fix case were the end of the file matches the start of magic, thanks Markus Duft for the report svn path=/main/branches/prefix/; revision=14408 --- src/chpathtool.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/chpathtool.c b/src/chpathtool.c index f2c92b7bb..999eb0a7a 100644 --- a/src/chpathtool.c +++ b/src/chpathtool.c @@ -1,4 +1,4 @@ -/* Copyright Gentoo Foundation 2006-2007 +/* Copyright Gentoo Foundation 2006-2009 * Author: Fabian Groffen * $Id$ * @@ -132,6 +132,11 @@ static int chpath(const char *fi, const char *fo) { len += pos; if ((tmp = memstr(buf, magic, len)) != NULL) { if (tmp == buf) { + if (len < magiclen) { + /* must be last piece */ + padding = padonwrite(padding, buf, len, fout); + break; + } /* do some magic, overwrite it basically */ fwrite(value, valuelen, 1, fout); /* store what we need to correct */ -- 2.26.2