Commit 14994715 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Avoid buffer underflow in find_dos_device().

parent 2dc0758b
......@@ -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 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment