[syslinux:elflink] ldlinux: fixes bug that happens when using fullpath for a COM32 module

syslinux-bot for Andre Ericson de.ericson at gmail.com
Tue Jun 26 09:54:05 PDT 2012


Commit-ID:  6bf3351711fe6c3f5731e519c2fbb298c6bcf2b4
Gitweb:     http://www.syslinux.org/commit/6bf3351711fe6c3f5731e519c2fbb298c6bcf2b4
Author:     Andre Ericson <de.ericson at gmail.com>
AuthorDate: Mon, 28 May 2012 06:54:15 -0300
Committer:  Matt Fleming <matt.fleming at intel.com>
CommitDate: Fri, 8 Jun 2012 08:10:22 +0100

ldlinux: fixes bug that happens when using fullpath for a COM32 module

When using full path for a com32 module, for example,
/boot/syslinux/ls.c32 it fails without any error message. This patch
fixes it by looking first if the argv[0] is the path to a module before
looking for it at PATH.

Since we're using fopen to open module files (which works for both
absolute paths and paths relative to the current working directory) we
no longer need to include "." in PATH and neither the code to handle it.

Signed-off-by: Andre Ericson <de.ericson at gmail.com>
Signed-off-by: Matt Fleming <matt.fleming at intel.com>

---
 com32/lib/sys/module/common.c |   13 ++++---------
 core/include/fs.h             |    2 +-
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/com32/lib/sys/module/common.c b/com32/lib/sys/module/common.c
index eeb2607..19742e6 100644
--- a/com32/lib/sys/module/common.c
+++ b/com32/lib/sys/module/common.c
@@ -64,6 +64,10 @@ static FILE *findpath(char *name)
 	char *p, *n;
 	int i;
 
+	f = fopen(name, "rb"); /* for full path */
+	if (f)
+		return f;
+
 	p = PATH;
 again:
 	i = 0;
@@ -74,15 +78,6 @@ again:
 	if (*p == ':')
 		p++;
 
-	if (path[0] == '.' && i == 1) {
-		if (!core_getcwd(path, sizeof(path))) {
-			DBG_PRINT("Could not get cwd\n");
-			return NULL;
-		}
-
-		i = strlen(path);
-	}
-
 	n = name;
 	while (*n && i < FILENAME_MAX)
 		path[i++] = *n++;
diff --git a/core/include/fs.h b/core/include/fs.h
index 481e085..ded8c15 100644
--- a/core/include/fs.h
+++ b/core/include/fs.h
@@ -179,7 +179,7 @@ static inline struct file *handle_to_file(uint16_t handle)
     return handle ? &files[handle-1] : NULL;
 }
 
-#define PATH_DEFAULT	".:/boot/syslinux/:/boot/"
+#define PATH_DEFAULT	"/boot/syslinux/:/boot/"
 extern char *PATH;
 
 /* fs.c */


More information about the Syslinux-commits mailing list