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
81c92239
Commit
81c92239
authored
Mar 03, 2007
by
Alasdair Sinclair
Committed by
Alexandre Julliard
Mar 09, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Fix GetComputerNameA to not count trailing NULL, with test.
parent
f2792521
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
6 deletions
+16
-6
computername.c
dlls/kernel32/computername.c
+5
-6
environ.c
dlls/kernel32/tests/environ.c
+11
-0
No files found.
dlls/kernel32/computername.c
View file @
81c92239
...
...
@@ -371,7 +371,7 @@ out:
BOOL
WINAPI
GetComputerNameA
(
LPSTR
name
,
LPDWORD
size
)
{
WCHAR
nameW
[
MAX_COMPUTERNAME_LENGTH
+
1
];
DWORD
sizeW
=
MAX_COMPUTERNAME_LENGTH
;
DWORD
sizeW
=
MAX_COMPUTERNAME_LENGTH
+
1
;
unsigned
int
len
;
BOOL
ret
;
...
...
@@ -381,17 +381,16 @@ BOOL WINAPI GetComputerNameA(LPSTR name, LPDWORD size)
/* for compatibility with Win9x */
__TRY
{
if
(
*
size
<
len
+
1
)
if
(
*
size
<
len
)
{
*
size
=
len
+
1
;
*
size
=
len
;
SetLastError
(
ERROR_MORE_DATA
);
ret
=
FALSE
;
}
else
else
{
WideCharToMultiByte
(
CP_ACP
,
0
,
nameW
,
-
1
,
name
,
len
,
NULL
,
0
);
name
[
len
]
=
0
;
*
size
=
len
;
*
size
=
len
-
1
;
ret
=
TRUE
;
}
}
...
...
dlls/kernel32/tests/environ.c
View file @
81c92239
...
...
@@ -239,6 +239,7 @@ static void test_GetComputerName(void)
LPSTR
name
;
LPWSTR
nameW
;
DWORD
error
;
int
name_len
;
size
=
0
;
ret
=
GetComputerNameA
((
LPSTR
)
0xdeadbeef
,
&
size
);
...
...
@@ -250,6 +251,16 @@ static void test_GetComputerName(void)
ok
(
ret
,
"GetComputerNameA failed with error %d
\n
"
,
GetLastError
());
HeapFree
(
GetProcessHeap
(),
0
,
name
);
size
=
MAX_COMPUTERNAME_LENGTH
+
1
;
name
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
*
sizeof
(
name
[
0
]));
ok
(
name
!=
NULL
,
"HeapAlloc failed with error %d
\n
"
,
GetLastError
());
ret
=
GetComputerNameA
(
name
,
&
size
);
ok
(
ret
,
"GetComputerNameA failed with error %d
\n
"
,
GetLastError
());
trace
(
"computer name is
\"
%s
\"\n
"
,
name
);
name_len
=
strlen
(
name
);
ok
(
size
==
name_len
,
"size should be same as length, name_len=%d, size=%d
\n
"
,
name_len
,
size
);
HeapFree
(
GetProcessHeap
(),
0
,
name
);
size
=
0
;
ret
=
GetComputerNameW
((
LPWSTR
)
0xdeadbeef
,
&
size
);
error
=
GetLastError
();
...
...
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