fix case were the end of the file matches the start of magic, thanks Markus Duft...
authorFabian Groffen <grobian@gentoo.org>
Thu, 24 Sep 2009 17:53:01 +0000 (17:53 -0000)
committerFabian Groffen <grobian@gentoo.org>
Thu, 24 Sep 2009 17:53:01 +0000 (17:53 -0000)
svn path=/main/branches/prefix/; revision=14408

src/chpathtool.c

index f2c92b7bbb3e9fb771ef9e0e67f8fd1f1e2f7e57..999eb0a7a44b97a4461f9decd6281d054288b7c2 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright Gentoo Foundation 2006-2007
+/* Copyright Gentoo Foundation 2006-2009
  * Author: Fabian Groffen <grobian@gentoo.org>
  * $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 */