From af8b6e9bdf9d7e9d059c1732ccd5d4007e5ca08c Mon Sep 17 00:00:00 2001 From: Matt Fleming Date: Tue, 12 Jul 2011 16:21:37 +0100 Subject: [PATCH] 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 Signed-off-by: H. Peter Anvin --- core/fs/pxe/pxe.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/fs/pxe/pxe.c b/core/fs/pxe/pxe.c index 3e5d172..17d9125 100644 --- a/core/fs/pxe/pxe.c +++ b/core/fs/pxe/pxe.c @@ -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"); -- 2.7.4