Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
516b21f4
Commit
516b21f4
authored
Jul 23, 2015
by
Nikolay Sivov
Committed by
Alexandre Julliard
Jul 28, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user32: Don't send WM_GETTEXT from GetWindowText() with invalid buffer length.
parent
ee72b0fd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
19 deletions
+6
-19
win.c
dlls/user32/tests/win.c
+2
-11
win.c
dlls/user32/win.c
+4
-8
No files found.
dlls/user32/tests/win.c
View file @
516b21f4
...
@@ -722,7 +722,6 @@ static struct wm_gettext_override_data
...
@@ -722,7 +722,6 @@ static struct wm_gettext_override_data
BOOL
enabled
;
/* when 1 bypasses default procedure */
BOOL
enabled
;
/* when 1 bypasses default procedure */
char
*
buff
;
/* expected text buffer pointer */
char
*
buff
;
/* expected text buffer pointer */
WCHAR
*
buffW
;
/* same, for W test */
WCHAR
*
buffW
;
/* same, for W test */
int
len
;
}
g_wm_gettext_override
;
}
g_wm_gettext_override
;
static
LRESULT
WINAPI
main_window_procA
(
HWND
hwnd
,
UINT
msg
,
WPARAM
wparam
,
LPARAM
lparam
)
static
LRESULT
WINAPI
main_window_procA
(
HWND
hwnd
,
UINT
msg
,
WPARAM
wparam
,
LPARAM
lparam
)
...
@@ -810,8 +809,7 @@ static LRESULT WINAPI main_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPAR
...
@@ -810,8 +809,7 @@ static LRESULT WINAPI main_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPAR
{
{
char
*
text
=
(
char
*
)
lparam
;
char
*
text
=
(
char
*
)
lparam
;
ok
(
g_wm_gettext_override
.
buff
==
text
,
"expected buffer %p, got %p
\n
"
,
g_wm_gettext_override
.
buff
,
text
);
ok
(
g_wm_gettext_override
.
buff
==
text
,
"expected buffer %p, got %p
\n
"
,
g_wm_gettext_override
.
buff
,
text
);
if
(
g_wm_gettext_override
.
len
)
ok
(
*
text
==
0
,
"expected empty string buffer %x
\n
"
,
*
text
);
ok
(
*
text
==
0
,
"expected empty string buffer %x
\n
"
,
*
text
);
return
0
;
return
0
;
}
}
break
;
break
;
...
@@ -833,8 +831,7 @@ static LRESULT WINAPI main_window_procW(HWND hwnd, UINT msg, WPARAM wparam, LPAR
...
@@ -833,8 +831,7 @@ static LRESULT WINAPI main_window_procW(HWND hwnd, UINT msg, WPARAM wparam, LPAR
{
{
WCHAR
*
text
=
(
WCHAR
*
)
lparam
;
WCHAR
*
text
=
(
WCHAR
*
)
lparam
;
ok
(
g_wm_gettext_override
.
buffW
==
text
,
"expected buffer %p, got %p
\n
"
,
g_wm_gettext_override
.
buffW
,
text
);
ok
(
g_wm_gettext_override
.
buffW
==
text
,
"expected buffer %p, got %p
\n
"
,
g_wm_gettext_override
.
buffW
,
text
);
if
(
g_wm_gettext_override
.
len
)
ok
(
*
text
==
0
,
"expected empty string buffer %x
\n
"
,
*
text
);
ok
(
*
text
==
0
,
"expected empty string buffer %x
\n
"
,
*
text
);
return
0
;
return
0
;
}
}
break
;
break
;
...
@@ -5819,7 +5816,6 @@ static void test_gettext(void)
...
@@ -5819,7 +5816,6 @@ static void test_gettext(void)
num_gettext_msgs
=
0
;
num_gettext_msgs
=
0
;
memset
(
buf
,
0xcc
,
sizeof
(
buf
)
);
memset
(
buf
,
0xcc
,
sizeof
(
buf
)
);
g_wm_gettext_override
.
buff
=
buf
;
g_wm_gettext_override
.
buff
=
buf
;
g_wm_gettext_override
.
len
=
sizeof
(
buf
);
buf_len
=
GetWindowTextA
(
hwnd
,
buf
,
sizeof
(
buf
)
);
buf_len
=
GetWindowTextA
(
hwnd
,
buf
,
sizeof
(
buf
)
);
ok
(
buf_len
==
0
,
"got %d
\n
"
,
buf_len
);
ok
(
buf_len
==
0
,
"got %d
\n
"
,
buf_len
);
ok
(
*
buf
==
0
,
"got %x
\n
"
,
*
buf
);
ok
(
*
buf
==
0
,
"got %x
\n
"
,
*
buf
);
...
@@ -5828,11 +5824,9 @@ static void test_gettext(void)
...
@@ -5828,11 +5824,9 @@ static void test_gettext(void)
num_gettext_msgs
=
0
;
num_gettext_msgs
=
0
;
strcpy
(
buf
,
"blah"
);
strcpy
(
buf
,
"blah"
);
g_wm_gettext_override
.
buff
=
buf
;
g_wm_gettext_override
.
buff
=
buf
;
g_wm_gettext_override
.
len
=
0
;
buf_len
=
GetWindowTextA
(
hwnd
,
buf
,
0
);
buf_len
=
GetWindowTextA
(
hwnd
,
buf
,
0
);
ok
(
buf_len
==
0
,
"got %d
\n
"
,
buf_len
);
ok
(
buf_len
==
0
,
"got %d
\n
"
,
buf_len
);
ok
(
!
strcmp
(
buf
,
"blah"
),
"got %s
\n
"
,
buf
);
ok
(
!
strcmp
(
buf
,
"blah"
),
"got %s
\n
"
,
buf
);
todo_wine
ok
(
num_gettext_msgs
==
0
,
"got %u WM_GETTEXT messages
\n
"
,
num_gettext_msgs
);
ok
(
num_gettext_msgs
==
0
,
"got %u WM_GETTEXT messages
\n
"
,
num_gettext_msgs
);
g_wm_gettext_override
.
enabled
=
FALSE
;
g_wm_gettext_override
.
enabled
=
FALSE
;
...
@@ -5846,7 +5840,6 @@ todo_wine
...
@@ -5846,7 +5840,6 @@ todo_wine
num_gettext_msgs
=
0
;
num_gettext_msgs
=
0
;
memset
(
bufW
,
0xcc
,
sizeof
(
bufW
)
);
memset
(
bufW
,
0xcc
,
sizeof
(
bufW
)
);
g_wm_gettext_override
.
buffW
=
bufW
;
g_wm_gettext_override
.
buffW
=
bufW
;
g_wm_gettext_override
.
len
=
sizeof
(
bufW
)
/
sizeof
(
WCHAR
);
buf_len
=
GetWindowTextW
(
hwnd2
,
bufW
,
sizeof
(
bufW
)
/
sizeof
(
WCHAR
)
);
buf_len
=
GetWindowTextW
(
hwnd2
,
bufW
,
sizeof
(
bufW
)
/
sizeof
(
WCHAR
)
);
ok
(
buf_len
==
0
,
"got %d
\n
"
,
buf_len
);
ok
(
buf_len
==
0
,
"got %d
\n
"
,
buf_len
);
ok
(
*
bufW
==
0
,
"got %x
\n
"
,
*
bufW
);
ok
(
*
bufW
==
0
,
"got %x
\n
"
,
*
bufW
);
...
@@ -5855,11 +5848,9 @@ todo_wine
...
@@ -5855,11 +5848,9 @@ todo_wine
num_gettext_msgs
=
0
;
num_gettext_msgs
=
0
;
memset
(
bufW
,
0xcc
,
sizeof
(
bufW
)
);
memset
(
bufW
,
0xcc
,
sizeof
(
bufW
)
);
g_wm_gettext_override
.
buffW
=
bufW
;
g_wm_gettext_override
.
buffW
=
bufW
;
g_wm_gettext_override
.
len
=
0
;
buf_len
=
GetWindowTextW
(
hwnd2
,
bufW
,
0
);
buf_len
=
GetWindowTextW
(
hwnd2
,
bufW
,
0
);
ok
(
buf_len
==
0
,
"got %d
\n
"
,
buf_len
);
ok
(
buf_len
==
0
,
"got %d
\n
"
,
buf_len
);
ok
(
*
bufW
==
0xcccc
,
"got %x
\n
"
,
*
bufW
);
ok
(
*
bufW
==
0xcccc
,
"got %x
\n
"
,
*
bufW
);
todo_wine
ok
(
num_gettext_msgs
==
0
,
"got %u WM_GETTEXT messages
\n
"
,
num_gettext_msgs
);
ok
(
num_gettext_msgs
==
0
,
"got %u WM_GETTEXT messages
\n
"
,
num_gettext_msgs
);
g_wm_gettext_override
.
enabled
=
FALSE
;
g_wm_gettext_override
.
enabled
=
FALSE
;
...
...
dlls/user32/win.c
View file @
516b21f4
...
@@ -2676,17 +2676,15 @@ INT WINAPI GetWindowTextA( HWND hwnd, LPSTR lpString, INT nMaxCount )
...
@@ -2676,17 +2676,15 @@ INT WINAPI GetWindowTextA( HWND hwnd, LPSTR lpString, INT nMaxCount )
{
{
WCHAR
*
buffer
;
WCHAR
*
buffer
;
if
(
!
lpString
)
return
0
;
if
(
!
lpString
||
nMaxCount
<=
0
)
return
0
;
if
(
WIN_IsCurrentProcess
(
hwnd
))
if
(
WIN_IsCurrentProcess
(
hwnd
))
{
{
if
(
nMaxCount
>
0
)
lpString
[
0
]
=
0
;
lpString
[
0
]
=
0
;
return
(
INT
)
SendMessageA
(
hwnd
,
WM_GETTEXT
,
nMaxCount
,
(
LPARAM
)
lpString
);
return
(
INT
)
SendMessageA
(
hwnd
,
WM_GETTEXT
,
nMaxCount
,
(
LPARAM
)
lpString
);
}
}
/* when window belongs to other process, don't send a message */
/* when window belongs to other process, don't send a message */
if
(
nMaxCount
<=
0
)
return
0
;
if
(
!
(
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
nMaxCount
*
sizeof
(
WCHAR
)
)))
return
0
;
if
(
!
(
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
nMaxCount
*
sizeof
(
WCHAR
)
)))
return
0
;
get_server_window_text
(
hwnd
,
buffer
,
nMaxCount
);
get_server_window_text
(
hwnd
,
buffer
,
nMaxCount
);
if
(
!
WideCharToMultiByte
(
CP_ACP
,
0
,
buffer
,
-
1
,
lpString
,
nMaxCount
,
NULL
,
NULL
))
if
(
!
WideCharToMultiByte
(
CP_ACP
,
0
,
buffer
,
-
1
,
lpString
,
nMaxCount
,
NULL
,
NULL
))
...
@@ -2725,17 +2723,15 @@ INT WINAPI InternalGetWindowText(HWND hwnd,LPWSTR lpString,INT nMaxCount )
...
@@ -2725,17 +2723,15 @@ INT WINAPI InternalGetWindowText(HWND hwnd,LPWSTR lpString,INT nMaxCount )
*/
*/
INT
WINAPI
GetWindowTextW
(
HWND
hwnd
,
LPWSTR
lpString
,
INT
nMaxCount
)
INT
WINAPI
GetWindowTextW
(
HWND
hwnd
,
LPWSTR
lpString
,
INT
nMaxCount
)
{
{
if
(
!
lpString
)
return
0
;
if
(
!
lpString
||
nMaxCount
<=
0
)
return
0
;
if
(
WIN_IsCurrentProcess
(
hwnd
))
if
(
WIN_IsCurrentProcess
(
hwnd
))
{
{
if
(
nMaxCount
>
0
)
lpString
[
0
]
=
0
;
lpString
[
0
]
=
0
;
return
(
INT
)
SendMessageW
(
hwnd
,
WM_GETTEXT
,
nMaxCount
,
(
LPARAM
)
lpString
);
return
(
INT
)
SendMessageW
(
hwnd
,
WM_GETTEXT
,
nMaxCount
,
(
LPARAM
)
lpString
);
}
}
/* when window belongs to other process, don't send a message */
/* when window belongs to other process, don't send a message */
if
(
nMaxCount
<=
0
)
return
0
;
get_server_window_text
(
hwnd
,
lpString
,
nMaxCount
);
get_server_window_text
(
hwnd
,
lpString
,
nMaxCount
);
return
strlenW
(
lpString
);
return
strlenW
(
lpString
);
}
}
...
...
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