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
dccd41a8
Commit
dccd41a8
authored
Feb 06, 2006
by
Eric Pouech
Committed by
Alexandre Julliard
Feb 06, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel: Fixed regression in atom handling.
Added proper tests (local & global functions).
parent
2d0ad094
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
1 deletion
+46
-1
atom.c
dlls/kernel/atom.c
+4
-1
atom.c
dlls/kernel/tests/atom.c
+33
-0
atom.c
dlls/ntdll/tests/atom.c
+9
-0
No files found.
dlls/kernel/atom.c
View file @
dccd41a8
...
@@ -485,12 +485,15 @@ UINT WINAPI GlobalGetAtomNameW( ATOM atom, LPWSTR buffer, INT count )
...
@@ -485,12 +485,15 @@ UINT WINAPI GlobalGetAtomNameW( ATOM atom, LPWSTR buffer, INT count )
{
{
length
=
min
(
abi
->
NameLength
/
sizeof
(
WCHAR
),
count
);
length
=
min
(
abi
->
NameLength
/
sizeof
(
WCHAR
),
count
);
memcpy
(
buffer
,
abi
->
Name
,
length
*
sizeof
(
WCHAR
)
);
memcpy
(
buffer
,
abi
->
Name
,
length
*
sizeof
(
WCHAR
)
);
/* yes, the string will not be null terminated if the passed buffer
* is one WCHAR too small (and it's not an error)
*/
if
(
length
<
abi
->
NameLength
/
sizeof
(
WCHAR
))
if
(
length
<
abi
->
NameLength
/
sizeof
(
WCHAR
))
{
{
SetLastError
(
ERROR_MORE_DATA
);
SetLastError
(
ERROR_MORE_DATA
);
length
=
count
;
length
=
count
;
}
}
else
buffer
[
length
]
=
'\0'
;
else
if
(
length
<
count
)
buffer
[
length
]
=
'\0'
;
}
}
return
length
;
return
length
;
}
}
...
...
dlls/kernel/tests/atom.c
View file @
dccd41a8
...
@@ -220,6 +220,21 @@ static void test_get_atom_name(void)
...
@@ -220,6 +220,21 @@ static void test_get_atom_name(void)
}
}
}
}
memset
(
buf
,
'.'
,
sizeof
(
buf
)
);
len
=
GlobalGetAtomNameA
(
atom
,
buf
,
6
);
ok
(
len
==
0
,
"bad length %d
\n
"
,
len
);
ok
(
!
memcmp
(
buf
,
"fooba
\0
...."
,
10
),
"bad buffer contents
\n
"
);
if
(
unicode_OS
)
{
static
const
WCHAR
resW
[]
=
{
'f'
,
'o'
,
'o'
,
'b'
,
'a'
,
'r'
,
'.'
,
'.'
,
'.'
,
'.'
};
for
(
len
=
0
;
len
<
10
;
len
++
)
bufW
[
len
]
=
'.'
;
SetLastError
(
0xdeadbeef
);
len
=
GlobalGetAtomNameW
(
atom
,
bufW
,
6
);
ok
(
len
&&
GetLastError
()
==
0xdeadbeef
,
"GlobalGetAtomNameW failed
\n
"
);
ok
(
len
==
lstrlenW
(
foobarW
),
"bad length %d
\n
"
,
len
);
ok
(
!
memcmp
(
bufW
,
resW
,
10
*
sizeof
(
WCHAR
)
),
"bad buffer contents
\n
"
);
}
/* test string limits & overflow */
/* test string limits & overflow */
do_initA
(
in
,
"abcdefghij"
,
255
);
do_initA
(
in
,
"abcdefghij"
,
255
);
atom
=
GlobalAddAtomA
(
in
);
atom
=
GlobalAddAtomA
(
in
);
...
@@ -428,6 +443,24 @@ static void test_local_get_atom_name(void)
...
@@ -428,6 +443,24 @@ static void test_local_get_atom_name(void)
ok
(
!
memcmp
(
bufW
,
resultW
,
10
*
sizeof
(
WCHAR
)
),
"bad buffer contents
\n
"
);
ok
(
!
memcmp
(
bufW
,
resultW
,
10
*
sizeof
(
WCHAR
)
),
"bad buffer contents
\n
"
);
}
}
/* Get the name of the atom we added above */
memset
(
buf
,
'.'
,
sizeof
(
buf
)
);
len
=
GetAtomNameA
(
atom
,
buf
,
6
);
ok
(
len
==
5
,
"bad length %d
\n
"
,
len
);
ok
(
!
memcmp
(
buf
,
"fooba
\0
...."
,
10
),
"bad buffer contents
\n
"
);
/* Repeat, unicode-style */
if
(
unicode_OS
)
{
WCHAR
resW
[]
=
{
'f'
,
'o'
,
'o'
,
'b'
,
'a'
,
'\0'
,
'.'
,
'.'
,
'.'
,
'.'
};
for
(
i
=
0
;
i
<
10
;
i
++
)
bufW
[
i
]
=
'.'
;
SetLastError
(
0xdeadbeef
);
len
=
GetAtomNameW
(
atom
,
bufW
,
6
);
ok
(
len
&&
GetLastError
()
==
0xdeadbeef
,
"GlobalGetAtomNameW failed
\n
"
);
ok
(
len
==
5
,
"bad length %d
\n
"
,
len
);
ok
(
!
memcmp
(
bufW
,
resW
,
10
*
sizeof
(
WCHAR
)
),
"bad buffer contents
\n
"
);
}
/* Check error code returns */
/* Check error code returns */
memset
(
buf
,
'.'
,
10
);
memset
(
buf
,
'.'
,
10
);
ok
(
!
GetAtomNameA
(
atom
,
buf
,
0
),
"succeeded
\n
"
);
ok
(
!
GetAtomNameA
(
atom
,
buf
,
0
),
"succeeded
\n
"
);
...
...
dlls/ntdll/tests/atom.c
View file @
dccd41a8
...
@@ -207,6 +207,15 @@ static void test_NtAtom(void)
...
@@ -207,6 +207,15 @@ static void test_NtAtom(void)
ok
(
!
Name
[
3
],
"wrong string termination
\n
"
);
ok
(
!
Name
[
3
],
"wrong string termination
\n
"
);
ok
(
Name
[
4
]
==
0x55AA
,
"buffer overwrite
\n
"
);
ok
(
Name
[
4
]
==
0x55AA
,
"buffer overwrite
\n
"
);
Len
=
lstrlenW
(
testAtom2
)
*
sizeof
(
WCHAR
);
memset
(
Name
,
'.'
,
sizeof
(
Name
));
res
=
pRtlQueryAtomInAtomTable
(
AtomTable
,
Atom2
,
NULL
,
NULL
,
Name
,
&
Len
);
ok
(
!
res
,
"query atom %lx
\n
"
,
res
);
ok
(
Len
==
(
lstrlenW
(
testAtom2
)
-
1
)
*
sizeof
(
WCHAR
),
"wrong length %lu
\n
"
,
Len
);
ok
(
!
memcmp
(
testAtom2
,
Name
,
(
lstrlenW
(
testAtom2
)
-
1
)
*
sizeof
(
WCHAR
)),
"wrong atom name
\n
"
);
ok
(
Name
[
lstrlenW
(
testAtom2
)
-
1
]
==
'\0'
,
"wrong char
\n
"
);
ok
(
Name
[
lstrlenW
(
testAtom2
)]
==
(
'.'
<<
8
)
+
'.'
,
"wrong char
\n
"
);
res
=
pRtlLookupAtomInAtomTable
(
AtomTable
,
testAtom2
,
&
testAtom
);
res
=
pRtlLookupAtomInAtomTable
(
AtomTable
,
testAtom2
,
&
testAtom
);
ok
(
!
res
,
"We can't find our pinned atom!! retval: %lx
\n
"
,
res
);
ok
(
!
res
,
"We can't find our pinned atom!! retval: %lx
\n
"
,
res
);
ok
(
testAtom
==
Atom2
,
"We found wrong atom!!!
\n
"
);
ok
(
testAtom
==
Atom2
,
"We found wrong atom!!!
\n
"
);
...
...
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