From: Matt Fleming Date: Tue, 12 Jul 2011 15:12:48 +0000 (+0100) Subject: pxelinux: open_file() returns a non-negative handle X-Git-Tag: syslinux-5.00-pre1~37^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bfc2d6c221b8d85dcfeb65cdb7d0f91f03020cf7;p=platform%2Fupstream%2Fsyslinux.git 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 --- 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");