aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2010-12-06 15:54:24 -0800
committerH. Peter Anvin <hpa@linux.intel.com>2010-12-06 15:58:49 -0800
commitbddb395f4e52f1a0db32a852f1be4a244719f331 (patch)
treefddc368af67d5632a0bbbd2a6f2c21043061ffdb
parent77dcc0710a788dcdb866d6b0b76057aaadf36ec7 (diff)
downloadsyslinux-bddb395f4e52f1a0db32a852f1be4a244719f331.tar.gz
syslinux-bddb395f4e52f1a0db32a852f1be4a244719f331.tar.xz
syslinux-bddb395f4e52f1a0db32a852f1be4a244719f331.zip
com32: fix a ffile descriptor leak on open() of a nonexistent file
If we try to open a nonexistent file, free the resulting file descriptor. Reported-by: Antonio Carlini <arcarlini@iee.org> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r--com32/lib/sys/open.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/com32/lib/sys/open.c b/com32/lib/sys/open.c
index cb7c1b4d..3e7bb6cf 100644
--- a/com32/lib/sys/open.c
+++ b/com32/lib/sys/open.c
@@ -56,15 +56,17 @@ int open(const char *pathname, int flags, ...)
struct file_info *fp;
fd = opendev(&__file_dev, NULL, flags);
-
if (fd < 0)
return -1;
fp = &__file_info[fd];
handle = __com32.cs_pm->open_file(pathname, &fp->i.fd);
- if (handle < 0)
+ if (handle < 0) {
+ close(fd);
+ errno = ENOENT;
return -1;
+ }
fp->i.offset = 0;
fp->i.nbytes = 0;