From: Date: May 21 2005 7:34pm Subject: bk commit into 4.1 tree (reggie:1.2288) BUG#9148 List-Archive: http://lists.mysql.com/internals/25161 X-Bug: 9148 Message-Id: <200505211734.j4LHYaJm006213@mdk10> Below is the list of changes that have just been committed into a local 4.1 repository of reggie. When reggie does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet 1.2288 05/05/21 12:31:58 reggie@mdk10.(none) +2 -0 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. mysys/my_open.c 1.19 05/05/21 12:31:45 reggie@mdk10.(none) +6 -0 on Windows, if we are not creating a file the we call my_access to make sure the file exists before trying to open it. mysys/my_fopen.c 1.10 05/05/21 12:31:45 reggie@mdk10.(none) +15 -3 on Windows, if we are not creating a file the we call my_access to make sure the file exists before trying to open it. # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: reggie # Host: mdk10.(none) # Root: /home/reggie/bk/bug9148 --- 1.9/mysys/my_fopen.c 2004-08-23 05:46:49 -05:00 +++ 1.10/mysys/my_fopen.c 2005-05-21 12:31:45 -05:00 @@ -33,9 +33,21 @@ DBUG_ENTER("my_fopen"); DBUG_PRINT("my",("Name: '%s' Flags: %d MyFlags: %d", FileName, Flags, MyFlags)); - - make_ftype(type,Flags); - if ((fd = fopen(FileName, type)) != 0) + /* + * 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 + */ +#ifdef __WIN__ + if (! (Flags & O_CREAT) && my_access(FileName, F_OK)) + fd=0; + else +#endif + { + make_ftype(type,Flags); + fd = fopen(FileName, type); + } + + if (fd != 0) { /* The test works if MY_NFILE < 128. The problem is that fileno() is char --- 1.18/mysys/my_open.c 2004-02-19 11:33:03 -06:00 +++ 1.19/mysys/my_open.c 2005-05-21 12:31:45 -05:00 @@ -46,6 +46,12 @@ 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);