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

syslinux-bot for Matt Fleming matt.fleming at linux.intel.com
Thu Jul 28 14:06:14 PDT 2011


Commit-ID:  bfc2d6c221b8d85dcfeb65cdb7d0f91f03020cf7
Gitweb:     http://syslinux.zytor.com/commit/bfc2d6c221b8d85dcfeb65cdb7d0f91f03020cf7
Author:     Matt Fleming <matt.fleming at linux.intel.com>
AuthorDate: Tue, 12 Jul 2011 16:12:48 +0100
Committer:  Matt Fleming <matt.fleming at linux.intel.com>
CommitDate: Tue, 12 Jul 2011 16:24:06 +0100

pxelinux: open_file() returns a non-negative handle

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 573efe3..7b63d17 100644
--- a/core/fs/pxe/pxe.c
+++ b/core/fs/pxe/pxe.c
@@ -1064,7 +1064,7 @@ static int pxe_open_config(struct com32_filedata *filedata)
 
     if (DHCPMagic & 0x02) {
         /* We got a DHCP option, try it first */
-	if (!open_file(ConfigName, filedata))
+	if (open_file(ConfigName, filedata) >= 0)
 	    return 0;
     }
 
@@ -1076,13 +1076,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... */
@@ -1090,7 +1090,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--;
@@ -1098,7 +1098,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");



More information about the Syslinux-commits mailing list