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
ebec0a96
Commit
ebec0a96
authored
Mar 31, 2008
by
Paul Vriens
Committed by
Alexandre Julliard
Apr 01, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
setupapi: Fix for SetupGetIntField, with tests.
parent
14f86f87
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
8 deletions
+75
-8
parser.c
dlls/setupapi/parser.c
+13
-8
parser.c
dlls/setupapi/tests/parser.c
+62
-0
No files found.
dlls/setupapi/parser.c
View file @
ebec0a96
...
...
@@ -1711,21 +1711,26 @@ BOOL WINAPI SetupGetIntField( PINFCONTEXT context, DWORD index, PINT result )
char
*
end
,
*
buffer
=
localbuff
;
DWORD
required
;
INT
res
;
BOOL
ret
=
FALSE
;
BOOL
ret
;
if
(
!
SetupGetStringFieldA
(
context
,
index
,
localbuff
,
sizeof
(
localbuff
),
&
required
))
if
(
!
(
ret
=
SetupGetStringFieldA
(
context
,
index
,
localbuff
,
sizeof
(
localbuff
),
&
required
)
))
{
if
(
GetLastError
()
!=
ERROR_INSUFFICIENT_BUFFER
)
return
FALSE
;
if
(
!
(
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
required
)))
return
FALSE
;
if
(
!
SetupGetStringFieldA
(
context
,
index
,
buffer
,
required
,
NULL
))
goto
done
;
if
(
!
(
ret
=
SetupGetStringFieldA
(
context
,
index
,
buffer
,
required
,
NULL
)
))
goto
done
;
}
res
=
strtol
(
buffer
,
&
end
,
0
);
if
(
end
!=
buffer
&&
!*
end
)
/* The call to SetupGetStringFieldA succeeded. If buffer is empty we have an optional field */
if
(
!*
buffer
)
*
result
=
0
;
else
{
*
result
=
res
;
ret
=
TRUE
;
res
=
strtol
(
buffer
,
&
end
,
0
);
if
(
end
!=
buffer
&&
!*
end
)
*
result
=
res
;
else
{
SetLastError
(
ERROR_INVALID_DATA
);
ret
=
FALSE
;
}
}
else
SetLastError
(
ERROR_INVALID_DATA
);
done:
if
(
buffer
!=
localbuff
)
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
...
...
dlls/setupapi/tests/parser.c
View file @
ebec0a96
...
...
@@ -475,6 +475,67 @@ static void test_pSetupGetField(void)
SetupCloseInfFile
(
hinf
);
}
static
void
test_SetupGetIntField
(
void
)
{
static
const
struct
{
const
char
*
key
;
const
char
*
fields
;
DWORD
index
;
INT
value
;
DWORD
err
;
}
keys
[]
=
{
/* key fields index expected int errorcode */
{
"Key="
,
"48"
,
1
,
48
,
ERROR_SUCCESS
},
{
"Key="
,
"48"
,
0
,
-
1
,
ERROR_INVALID_DATA
},
{
"123="
,
"48"
,
0
,
123
,
ERROR_SUCCESS
},
{
"Key="
,
"0x4"
,
1
,
4
,
ERROR_SUCCESS
},
{
"Key="
,
"Field1"
,
1
,
-
1
,
ERROR_INVALID_DATA
},
{
"Key="
,
"Field1,34"
,
2
,
34
,
ERROR_SUCCESS
},
{
"Key="
,
"Field1,,Field3"
,
2
,
0
,
ERROR_SUCCESS
},
{
"Key="
,
"Field1,"
,
2
,
0
,
ERROR_SUCCESS
}
};
unsigned
int
i
;
for
(
i
=
0
;
i
<
sizeof
(
keys
)
/
sizeof
(
keys
[
0
]);
i
++
)
{
HINF
hinf
;
char
buffer
[
MAX_INF_STRING_LENGTH
];
INFCONTEXT
context
;
UINT
err
;
BOOL
retb
;
INT
intfield
;
strcpy
(
buffer
,
STD_HEADER
"[TestSection]
\n
"
);
strcat
(
buffer
,
keys
[
i
].
key
);
strcat
(
buffer
,
keys
[
i
].
fields
);
hinf
=
test_file_contents
(
buffer
,
&
err
);
ok
(
hinf
!=
NULL
,
"Expected valid INF file
\n
"
);
SetupFindFirstLineA
(
hinf
,
"TestSection"
,
"Key"
,
&
context
);
SetLastError
(
0xdeadbeef
);
intfield
=
-
1
;
retb
=
SetupGetIntField
(
&
context
,
keys
[
i
].
index
,
&
intfield
);
if
(
keys
[
i
].
err
==
ERROR_SUCCESS
)
{
ok
(
retb
,
"Expected success
\n
"
);
ok
(
GetLastError
()
==
ERROR_SUCCESS
||
GetLastError
()
==
0xdeadbeef
/* win9x, NT4 */
,
"Expected ERROR_SUCCESS or 0xdeadbeef, got %u
\n
"
,
GetLastError
()
);
}
else
{
ok
(
!
retb
,
"Expected failure
\n
"
);
ok
(
GetLastError
()
==
keys
[
i
].
err
,
"Expected %d, got %u
\n
"
,
keys
[
i
].
err
,
GetLastError
()
);
}
ok
(
intfield
==
keys
[
i
].
value
,
"Expected %d, got %d
\n
"
,
keys
[
i
].
value
,
intfield
);
SetupCloseInfFile
(
hinf
);
}
}
static
void
test_GLE
(
void
)
{
static
const
char
*
inf
=
...
...
@@ -597,6 +658,7 @@ START_TEST(parser)
test_key_names
();
test_close_inf_file
();
test_pSetupGetField
();
test_SetupGetIntField
();
test_GLE
();
DeleteFileA
(
tmpfilename
);
}
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