Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
054a95a8
Commit
054a95a8
authored
Mar 22, 2024
by
Paul Gofman
Committed by
Alexandre Julliard
Mar 26, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
win32u: Avoid writing past allocated memory in peek_message().
parent
8b7ac247
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
18 deletions
+20
-18
message.c
dlls/win32u/message.c
+20
-18
No files found.
dlls/win32u/message.c
View file @
054a95a8
...
@@ -469,9 +469,13 @@ static inline void push_string( struct packed_message *data, LPCWSTR str )
...
@@ -469,9 +469,13 @@ static inline void push_string( struct packed_message *data, LPCWSTR str )
}
}
/* make sure that there is space for 'size' bytes in buffer, growing it if needed */
/* make sure that there is space for 'size' bytes in buffer, growing it if needed */
static
inline
void
*
get_buffer_space
(
void
**
buffer
,
size_t
size
,
size_t
prev
_size
)
static
inline
void
*
get_buffer_space
(
void
**
buffer
,
size_t
size
,
size_t
*
buffer
_size
)
{
{
if
(
prev_size
<
size
)
*
buffer
=
malloc
(
size
);
if
(
*
buffer_size
<
size
)
{
*
buffer
=
malloc
(
size
);
*
buffer_size
=
size
;
}
return
*
buffer
;
return
*
buffer
;
}
}
...
@@ -522,7 +526,7 @@ BOOL set_keyboard_auto_repeat( BOOL enable )
...
@@ -522,7 +526,7 @@ BOOL set_keyboard_auto_repeat( BOOL enable )
* Unpack a message received from another process.
* Unpack a message received from another process.
*/
*/
static
BOOL
unpack_message
(
HWND
hwnd
,
UINT
message
,
WPARAM
*
wparam
,
LPARAM
*
lparam
,
static
BOOL
unpack_message
(
HWND
hwnd
,
UINT
message
,
WPARAM
*
wparam
,
LPARAM
*
lparam
,
void
**
buffer
,
size_t
size
)
void
**
buffer
,
size_t
size
,
size_t
*
buffer_size
)
{
{
size_t
minsize
=
0
;
size_t
minsize
=
0
;
union
packed_structs
*
ps
=
*
buffer
;
union
packed_structs
*
ps
=
*
buffer
;
...
@@ -585,7 +589,7 @@ static BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lpa
...
@@ -585,7 +589,7 @@ static BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lpa
break
;
break
;
case
WM_GETTEXT
:
case
WM_GETTEXT
:
case
WM_ASKCBFORMATNAME
:
case
WM_ASKCBFORMATNAME
:
if
(
!
get_buffer_space
(
buffer
,
(
*
wparam
*
sizeof
(
WCHAR
)),
size
))
return
FALSE
;
if
(
!
get_buffer_space
(
buffer
,
(
*
wparam
*
sizeof
(
WCHAR
)),
buffer_
size
))
return
FALSE
;
break
;
break
;
case
WM_WININICHANGE
:
case
WM_WININICHANGE
:
if
(
!*
lparam
)
return
TRUE
;
if
(
!*
lparam
)
return
TRUE
;
...
@@ -726,17 +730,17 @@ static BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lpa
...
@@ -726,17 +730,17 @@ static BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lpa
minsize
=
sizeof
(
SCROLLINFO
);
minsize
=
sizeof
(
SCROLLINFO
);
break
;
break
;
case
SBM_GETSCROLLINFO
:
case
SBM_GETSCROLLINFO
:
if
(
!
get_buffer_space
(
buffer
,
sizeof
(
SCROLLINFO
),
size
))
return
FALSE
;
if
(
!
get_buffer_space
(
buffer
,
sizeof
(
SCROLLINFO
),
buffer_
size
))
return
FALSE
;
break
;
break
;
case
SBM_GETSCROLLBARINFO
:
case
SBM_GETSCROLLBARINFO
:
if
(
!
get_buffer_space
(
buffer
,
sizeof
(
SCROLLBARINFO
),
size
))
return
FALSE
;
if
(
!
get_buffer_space
(
buffer
,
sizeof
(
SCROLLBARINFO
),
buffer_
size
))
return
FALSE
;
break
;
break
;
case
EM_GETSEL
:
case
EM_GETSEL
:
case
SBM_GETRANGE
:
case
SBM_GETRANGE
:
case
CB_GETEDITSEL
:
case
CB_GETEDITSEL
:
if
(
*
wparam
||
*
lparam
)
if
(
*
wparam
||
*
lparam
)
{
{
if
(
!
get_buffer_space
(
buffer
,
2
*
sizeof
(
DWORD
),
size
))
return
FALSE
;
if
(
!
get_buffer_space
(
buffer
,
2
*
sizeof
(
DWORD
),
buffer_
size
))
return
FALSE
;
if
(
*
wparam
)
*
wparam
=
(
WPARAM
)
*
buffer
;
if
(
*
wparam
)
*
wparam
=
(
WPARAM
)
*
buffer
;
if
(
*
lparam
)
*
lparam
=
(
LPARAM
)((
DWORD
*
)
*
buffer
+
1
);
if
(
*
lparam
)
*
lparam
=
(
LPARAM
)((
DWORD
*
)
*
buffer
+
1
);
}
}
...
@@ -744,7 +748,7 @@ static BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lpa
...
@@ -744,7 +748,7 @@ static BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lpa
case
EM_GETRECT
:
case
EM_GETRECT
:
case
LB_GETITEMRECT
:
case
LB_GETITEMRECT
:
case
CB_GETDROPPEDCONTROLRECT
:
case
CB_GETDROPPEDCONTROLRECT
:
if
(
!
get_buffer_space
(
buffer
,
sizeof
(
RECT
),
size
))
return
FALSE
;
if
(
!
get_buffer_space
(
buffer
,
sizeof
(
RECT
),
buffer_
size
))
return
FALSE
;
break
;
break
;
case
EM_SETRECT
:
case
EM_SETRECT
:
case
EM_SETRECTNP
:
case
EM_SETRECTNP
:
...
@@ -755,7 +759,7 @@ static BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lpa
...
@@ -755,7 +759,7 @@ static BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lpa
WORD
*
len_ptr
,
len
;
WORD
*
len_ptr
,
len
;
if
(
size
<
sizeof
(
WORD
))
return
FALSE
;
if
(
size
<
sizeof
(
WORD
))
return
FALSE
;
len
=
*
(
WORD
*
)
*
buffer
;
len
=
*
(
WORD
*
)
*
buffer
;
if
(
!
get_buffer_space
(
buffer
,
(
len
+
1
)
*
sizeof
(
WCHAR
),
size
))
return
FALSE
;
if
(
!
get_buffer_space
(
buffer
,
(
len
+
1
)
*
sizeof
(
WCHAR
),
buffer_
size
))
return
FALSE
;
len_ptr
=
*
buffer
;
len_ptr
=
*
buffer
;
len_ptr
[
0
]
=
len_ptr
[
1
]
=
len
;
len_ptr
[
0
]
=
len_ptr
[
1
]
=
len
;
*
lparam
=
(
LPARAM
)(
len_ptr
+
1
);
*
lparam
=
(
LPARAM
)(
len_ptr
+
1
);
...
@@ -780,26 +784,24 @@ static BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lpa
...
@@ -780,26 +784,24 @@ static BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lpa
break
;
break
;
case
CB_GETLBTEXT
:
case
CB_GETLBTEXT
:
{
{
size_t
prev_size
=
size
;
if
(
combobox_has_strings
(
hwnd
))
if
(
combobox_has_strings
(
hwnd
))
size
=
(
send_message
(
hwnd
,
CB_GETLBTEXTLEN
,
*
wparam
,
0
)
+
1
)
*
sizeof
(
WCHAR
);
size
=
(
send_message
(
hwnd
,
CB_GETLBTEXTLEN
,
*
wparam
,
0
)
+
1
)
*
sizeof
(
WCHAR
);
else
else
size
=
sizeof
(
ULONG_PTR
);
size
=
sizeof
(
ULONG_PTR
);
if
(
!
get_buffer_space
(
buffer
,
size
,
prev
_size
))
return
FALSE
;
if
(
!
get_buffer_space
(
buffer
,
size
,
buffer
_size
))
return
FALSE
;
break
;
break
;
}
}
case
LB_GETTEXT
:
case
LB_GETTEXT
:
{
{
size_t
prev_size
=
size
;
if
(
listbox_has_strings
(
hwnd
))
if
(
listbox_has_strings
(
hwnd
))
size
=
(
send_message
(
hwnd
,
LB_GETTEXTLEN
,
*
wparam
,
0
)
+
1
)
*
sizeof
(
WCHAR
);
size
=
(
send_message
(
hwnd
,
LB_GETTEXTLEN
,
*
wparam
,
0
)
+
1
)
*
sizeof
(
WCHAR
);
else
else
size
=
sizeof
(
ULONG_PTR
);
size
=
sizeof
(
ULONG_PTR
);
if
(
!
get_buffer_space
(
buffer
,
size
,
prev
_size
))
return
FALSE
;
if
(
!
get_buffer_space
(
buffer
,
size
,
buffer
_size
))
return
FALSE
;
break
;
break
;
}
}
case
LB_GETSELITEMS
:
case
LB_GETSELITEMS
:
if
(
!
get_buffer_space
(
buffer
,
*
wparam
*
sizeof
(
UINT
),
size
))
return
FALSE
;
if
(
!
get_buffer_space
(
buffer
,
*
wparam
*
sizeof
(
UINT
),
buffer_
size
))
return
FALSE
;
break
;
break
;
case
WM_NEXTMENU
:
case
WM_NEXTMENU
:
{
{
...
@@ -814,7 +816,7 @@ static BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lpa
...
@@ -814,7 +816,7 @@ static BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lpa
case
WM_SIZING
:
case
WM_SIZING
:
case
WM_MOVING
:
case
WM_MOVING
:
minsize
=
sizeof
(
RECT
);
minsize
=
sizeof
(
RECT
);
if
(
!
get_buffer_space
(
buffer
,
sizeof
(
RECT
),
size
))
return
FALSE
;
if
(
!
get_buffer_space
(
buffer
,
sizeof
(
RECT
),
buffer_
size
))
return
FALSE
;
break
;
break
;
case
WM_MDICREATE
:
case
WM_MDICREATE
:
{
{
...
@@ -880,7 +882,7 @@ static BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lpa
...
@@ -880,7 +882,7 @@ static BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lpa
}
}
case
WM_MDIGETACTIVE
:
case
WM_MDIGETACTIVE
:
if
(
!*
lparam
)
return
TRUE
;
if
(
!*
lparam
)
return
TRUE
;
if
(
!
get_buffer_space
(
buffer
,
sizeof
(
BOOL
),
size
))
return
FALSE
;
if
(
!
get_buffer_space
(
buffer
,
sizeof
(
BOOL
),
buffer_
size
))
return
FALSE
;
break
;
break
;
case
WM_DEVICECHANGE
:
case
WM_DEVICECHANGE
:
if
(
!
(
*
wparam
&
0x8000
))
return
TRUE
;
if
(
!
(
*
wparam
&
0x8000
))
return
TRUE
;
...
@@ -2788,7 +2790,7 @@ int peek_message( MSG *msg, const struct peek_message_filter *filter )
...
@@ -2788,7 +2790,7 @@ int peek_message( MSG *msg, const struct peek_message_filter *filter )
case
MSG_NOTIFY
:
case
MSG_NOTIFY
:
info
.
flags
=
ISMEX_NOTIFY
;
info
.
flags
=
ISMEX_NOTIFY
;
if
(
!
unpack_message
(
info
.
msg
.
hwnd
,
info
.
msg
.
message
,
&
info
.
msg
.
wParam
,
if
(
!
unpack_message
(
info
.
msg
.
hwnd
,
info
.
msg
.
message
,
&
info
.
msg
.
wParam
,
&
info
.
msg
.
lParam
,
&
buffer
,
size
))
&
info
.
msg
.
lParam
,
&
buffer
,
size
,
&
buffer_size
))
continue
;
continue
;
break
;
break
;
case
MSG_CALLBACK
:
case
MSG_CALLBACK
:
...
@@ -2866,7 +2868,7 @@ int peek_message( MSG *msg, const struct peek_message_filter *filter )
...
@@ -2866,7 +2868,7 @@ int peek_message( MSG *msg, const struct peek_message_filter *filter )
case
MSG_OTHER_PROCESS
:
case
MSG_OTHER_PROCESS
:
info
.
flags
=
ISMEX_SEND
;
info
.
flags
=
ISMEX_SEND
;
if
(
!
unpack_message
(
info
.
msg
.
hwnd
,
info
.
msg
.
message
,
&
info
.
msg
.
wParam
,
if
(
!
unpack_message
(
info
.
msg
.
hwnd
,
info
.
msg
.
message
,
&
info
.
msg
.
wParam
,
&
info
.
msg
.
lParam
,
&
buffer
,
size
))
&
info
.
msg
.
lParam
,
&
buffer
,
size
,
&
buffer_size
))
{
{
/* ignore it */
/* ignore it */
reply_message
(
&
info
,
0
,
&
info
.
msg
);
reply_message
(
&
info
,
0
,
&
info
.
msg
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment