summaryrefslogtreecommitdiff
path: root/mysys/my_open.c
diff options
context:
space:
mode:
authorreggie@mdk10.(none) <>2005-05-21 12:31:58 -0500
committerreggie@mdk10.(none) <>2005-05-21 12:31:58 -0500
commit78b40d0a0ff0771842af25e08d3672c8b5836588 (patch)
tree1e3a7eeced13fbee15770b63f2c8c20e3a0d17d1 /mysys/my_open.c
parent2536b5933a02e2c0c5f7baa412494b587735e5ef (diff)
downloadmariadb-git-78b40d0a0ff0771842af25e08d3672c8b5836588.tar.gz
BUG# 9148: Denial of service
This is a second patch needing another review. The first patch didn't solve the entire problem. open and fopen on Windows will still open files like "com1.sym" when they shouldn't. This patch checks that the file exists before trying to open it.
Diffstat (limited to 'mysys/my_open.c')
-rw-r--r--mysys/my_open.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/mysys/my_open.c b/mysys/my_open.c
index ca5c0d8683f..1f3bb95b5a2 100644
--- a/mysys/my_open.c
+++ b/mysys/my_open.c
@@ -46,6 +46,12 @@ File my_open(const char *FileName, int Flags, myf MyFlags)
DBUG_PRINT("my",("Name: '%s' Flags: %d MyFlags: %d",
FileName, Flags, MyFlags));
#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__) || defined(OS2)
+ /* if we are not creating, then we need to use my_access to make
+ * sure the file exists since Windows doesn't handle files like
+ * "com1.sym" very well
+ */
+ if (! (Flags & O_CREAT) && my_access(FileName, F_OK))
+ return -1;
if (Flags & O_SHARE)
fd = sopen((my_string) FileName, (Flags & ~O_SHARE) | O_BINARY, SH_DENYNO,
MY_S_IREAD | MY_S_IWRITE);