Alexandre Julliard : ntdll: Avoid buffer underflow in find_dos_device().

Alexandre Julliard julliard at winehq.org
Thu Jul 16 19:01:20 CDT 2020


Module: wine
Branch: master
Commit: 14994715e9337821aeac39c0f43b704bdc7ba200
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=14994715e9337821aeac39c0f43b704bdc7ba200

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Jul 16 09:14:43 2020 +0200

ntdll: Avoid buffer underflow in find_dos_device().

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/unix/file.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c
index b202864e66..08b58ba828 100644
--- a/dlls/ntdll/unix/file.c
+++ b/dlls/ntdll/unix/file.c
@@ -1924,7 +1924,6 @@ static int find_dos_device( const char *path )
             {
                 if ((info[drive].dev == st.st_dev) && (info[drive].ino == st.st_ino))
                 {
-                    if (len == 1) len = 0;  /* preserve root slash in returned path */
                     TRACE( "%s -> drive %c:, root=%s, name=%s\n",
                            debugstr_a(path), 'A' + drive, debugstr_a(buffer), debugstr_a(path + len));
                     free( buffer );
@@ -1933,8 +1932,8 @@ static int find_dos_device( const char *path )
             }
         }
         if (len <= 1) break;  /* reached root */
-        while (path[len - 1] != '/') len--;
-        while (path[len - 1] == '/') len--;
+        while (len > 1 && path[len - 1] != '/') len--;
+        while (len > 1 && path[len - 1] == '/') len--;
         buffer[len] = 0;
     }
     free( buffer );
@@ -1952,7 +1951,6 @@ static NTSTATUS get_mountmgr_fs_info( HANDLE handle, int fd, struct mountmgr_uni
     int letter;
 
     if ((status = server_get_unix_name( handle, &unix_name ))) return status;
-
     letter = find_dos_device( unix_name );
     free( unix_name );
 




More information about the wine-cvs mailing list