core: always canonicalize the configuration file name
authorH. Peter Anvin <hpa@linux.intel.com>
Fri, 2 Jul 2010 23:01:19 +0000 (16:01 -0700)
committerH. Peter Anvin <hpa@linux.intel.com>
Fri, 2 Jul 2010 23:01:19 +0000 (16:01 -0700)
The FAT installers may not produce a canonical pathname in the
CurrentDirName field on entry.  Make sure that the core doesn't croak
when that happens, and still produces an absolute pathname for the
configuration file.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
core/fs/lib/loadconfig.c

index 356d5a2..db538b8 100644 (file)
@@ -13,6 +13,7 @@
  */
 int generic_load_config(void)
 {
+    char confignamebuf[FILENAME_MAX];
     static const char *search_directories[] = {
        NULL,                   /* CurrentDirName */
        "/boot/syslinux", 
@@ -36,9 +37,11 @@ int generic_load_config(void)
        const char *sd = search_directories[i];
        for (j = 0; filenames[j]; j++) {
            memset(&regs, 0, sizeof regs);
-           snprintf(ConfigName, FILENAME_MAX, "%s%s%s",
+           snprintf(confignamebuf, sizeof confignamebuf,
+                    "%s%s%s",
                     sd, (*sd && sd[strlen(sd)-1] == '/') ? "" : "/",
                     filenames[j]);
+           realpath(ConfigName, confignamebuf, FILENAME_MAX);
            regs.edi.w[0] = OFFS_WRT(ConfigName, 0);
            dprintf("Config search: %s\n", ConfigName);
            call16(core_open, &regs, &regs);