[syslinux:elflink] ldlinux: Only append missing filename extensions

syslinux-bot for Matt Fleming matt.fleming at intel.com
Thu Nov 29 05:33:06 PST 2012


Commit-ID:  556e76db9ba0d8f23770b839c9f42121b61d4348
Gitweb:     http://www.syslinux.org/commit/556e76db9ba0d8f23770b839c9f42121b61d4348
Author:     Matt Fleming <matt.fleming at intel.com>
AuthorDate: Thu, 29 Nov 2012 08:47:15 +0000
Committer:  Matt Fleming <matt.fleming at intel.com>
CommitDate: Thu, 29 Nov 2012 08:47:15 +0000

ldlinux: Only append missing filename extensions

Don't append an extension like ".c32" if the command already has one!
This bug lead to "config.c32" being executed as "config.c32.c32" with
the below config snippet,

    LABEL config
        COM32 config.c32 /configs/isolinux.cfg

Reported-by: Ady <ady-sf at hotmail.com>
Signed-off-by: Matt Fleming <matt.fleming at intel.com>

---
 com32/elflink/ldlinux/ldlinux.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/com32/elflink/ldlinux/ldlinux.c b/com32/elflink/ldlinux/ldlinux.c
index 82d2ae6..62db2f7 100644
--- a/com32/elflink/ldlinux/ldlinux.c
+++ b/com32/elflink/ldlinux/ldlinux.c
@@ -121,12 +121,15 @@ const char *apply_extension(const char *kernel, const char *ext)
 	memcpy(k, kernel, len);
 
 	/* Append the extension */
-	memcpy(k + len, ext, elen);
+	if (strncmp(p - elen, ext, elen)) {
+		memcpy(k + len, ext, elen);
+		len += elen;
+	}
 
 	/* Copy the rest of the command line */
-	strcpy(k + len + elen, p);
+	strcpy(k + len, p);
 
-	k[len + elen + strlen(p)] = '\0';
+	k[len + strlen(p)] = '\0';
 
 	return k;
 }


More information about the Syslinux-commits mailing list