[syslinux] [PATCH] pxelinux: open_file() returns a non-negative handle

Matt Fleming matt at console-pimps.org
Tue Jul 12 08:21:37 PDT 2011


From: Matt Fleming <matt.fleming at linux.intel.com>

The usage of open_file() is wrong in core/fs/pxe/pxe.c. Any
non-negative return value indicates success, not just a return value
of zero.

This bug was introduced in commit ba4fefa9b52b "core: change
load_config() to open_config()". The bug causes pxelinux to fail to
open configuration files.

Signed-off-by: Matt Fleming <matt.fleming at linux.intel.com>
---
 core/fs/pxe/pxe.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/core/fs/pxe/pxe.c b/core/fs/pxe/pxe.c
index f0f8b61..d689e61 100644
--- a/core/fs/pxe/pxe.c
+++ b/core/fs/pxe/pxe.c
@@ -1065,7 +1065,7 @@ static int pxe_open_config(struct com32_filedata *filedata)
     get_prefix();
     if (DHCPMagic & 0x02) {
         /* We got a DHCP option, try it first */
-	if (!open_file(ConfigName, filedata))
+	if (open_file(ConfigName, filedata) >= 0)
 	    return 0;
     }
 
@@ -1077,13 +1077,13 @@ static int pxe_open_config(struct com32_filedata *filedata)
     /* Try loading by UUID */
     if (have_uuid) {
 	strcpy(config_file, UUID_str);
-	if (!open_file(ConfigName, filedata))
+	if (open_file(ConfigName, filedata) >= 0)
             return 0;
     }
 
     /* Try loading by MAC address */
     strcpy(config_file, MAC_str);
-    if (!open_file(ConfigName, filedata))
+    if (open_file(ConfigName, filedata) >= 0)
         return 0;
 
     /* Nope, try hexadecimal IP prefixes... */
@@ -1091,7 +1091,7 @@ static int pxe_open_config(struct com32_filedata *filedata)
     last = &config_file[8];
     while (tries) {
         *last = '\0';        /* Zero-terminate string */
-	if (!open_file(ConfigName, filedata))
+	if (open_file(ConfigName, filedata) >= 0)
             return 0;
         last--;           /* Drop one character */
         tries--;
@@ -1099,7 +1099,7 @@ static int pxe_open_config(struct com32_filedata *filedata)
 
     /* Final attempt: "default" string */
     strcpy(config_file, default_str);
-    if (!open_file(ConfigName, filedata))
+    if (open_file(ConfigName, filedata) >= 0)
         return 0;
 
     printf("%-68s\n", "Unable to locate configuration file");
-- 
1.7.4.4




More information about the Syslinux mailing list