pxelinux: open_file() returns a non-negative handle
authorMatt Fleming <matt.fleming@linux.intel.com>
Tue, 12 Jul 2011 15:21:37 +0000 (16:21 +0100)
committerH. Peter Anvin <hpa@zytor.com>
Wed, 13 Jul 2011 03:01:03 +0000 (20:01 -0700)
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@linux.intel.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
core/fs/pxe/pxe.c

index 3e5d172..17d9125 100644 (file)
@@ -1059,7 +1059,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;
     }
 
@@ -1071,13 +1071,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... */
@@ -1085,7 +1085,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--;
@@ -1093,7 +1093,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");