diff options
author | Matt Fleming <matt.fleming@intel.com> | 2013-01-25 11:12:52 +0000 |
---|---|---|
committer | Matt Fleming <matt.fleming@intel.com> | 2013-01-25 11:19:02 +0000 |
commit | c250a42263c8717469c8a07d04567ce8333814dd (patch) | |
tree | 25783b6539021997b7c51fa3f85d17440181dfb0 | |
parent | b3be60133a334edf1bada24e4fd39d4c724e326e (diff) | |
download | syslinux-c250a42263c8717469c8a07d04567ce8333814dd.tar.gz syslinux-c250a42263c8717469c8a07d04567ce8333814dd.tar.xz syslinux-c250a42263c8717469c8a07d04567ce8333814dd.zip |
elflink: Set PATH to the directory containing ldlinux.c32syslinux-5.01-pre5
On ISOLINUX and PXELINUX, CurrentDirName doesn't contain anything
useful when we enter load_env32(). commit 10bb72d1528b ("PATH: Use
installation directory for 'PATH'") didn't handle the case where we
don't have an installation path, or don't find ldlinux.c32 there. If
we find ldlinux.c32 in one of 'search_directories' use that directory
as the PATH string.
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
-rw-r--r-- | core/elflink/load_env32.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/core/elflink/load_env32.c b/core/elflink/load_env32.c index 7a6b08fb..3ddbfec3 100644 --- a/core/elflink/load_env32.c +++ b/core/elflink/load_env32.c @@ -127,7 +127,7 @@ void load_env32(com32sys_t * regs __unused) PATH = malloc(strlen(CurrentDirName) + 1); if (!PATH) { printf("Couldn't allocate memory for PATH\n"); - return; + goto out; } strcpy(PATH, CurrentDirName); @@ -142,15 +142,36 @@ void load_env32(com32sys_t * regs __unused) * a bit harder to find LDLINUX. If search_dirs() succeeds * in finding LDLINUX it will set the cwd. */ + free(PATH); fd = opendev(&__file_dev, NULL, O_RDONLY); if (fd < 0) return; fp = &__file_info[fd]; - if (!search_dirs(&fp->i.fd, search_directories, filenames, realname)) + if (!search_dirs(&fp->i.fd, search_directories, filenames, realname)) { + char path[FILENAME_MAX]; + + /* + * search_dirs() sets the current working directory if + * it successfully opens the file. Set PATH to the + * directory in which we found ldlinux.c32. + */ + if (!core_getcwd(path, sizeof(path))) + goto out; + + PATH = malloc(strlen(path) + 1); + if (!PATH) { + printf("Couldn't allocate memory for PATH\n"); + goto out; + } + + strcpy(PATH, path); + start_ldlinux(argv); + } +out: writestr("\nFailed to load ldlinux.c32"); } |