mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 07:13:01 +00:00
Fix special case in SetupGetLineTextA/W and SetupGetStringFieldA/W when Buffer is NULL and BufferSize is 0, by reverting part of r17162
Fixes bug #724, spotted by GvG Do according changes in SetupDiBuildDriverInfoList svn path=/trunk/; revision=17483
This commit is contained in:
parent
05c41b4d84
commit
d373f6bfb0
2 changed files with 24 additions and 22 deletions
|
@ -3564,8 +3564,9 @@ SetupDiBuildDriverInfoList(
|
||||||
0, /* Field index */
|
0, /* Field index */
|
||||||
NULL, 0,
|
NULL, 0,
|
||||||
&RequiredSize);
|
&RequiredSize);
|
||||||
if (!Result && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
|
if (Result)
|
||||||
{
|
{
|
||||||
|
/* We got the needed size for the buffer */
|
||||||
ManufacturerName = HeapAlloc(GetProcessHeap(), 0, RequiredSize * sizeof(WCHAR));
|
ManufacturerName = HeapAlloc(GetProcessHeap(), 0, RequiredSize * sizeof(WCHAR));
|
||||||
if (!ManufacturerName)
|
if (!ManufacturerName)
|
||||||
{
|
{
|
||||||
|
@ -3583,8 +3584,9 @@ SetupDiBuildDriverInfoList(
|
||||||
1, /* Field index */
|
1, /* Field index */
|
||||||
NULL, 0,
|
NULL, 0,
|
||||||
&RequiredSize);
|
&RequiredSize);
|
||||||
if (!Result && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
|
if (Result)
|
||||||
{
|
{
|
||||||
|
/* We got the needed size for the buffer */
|
||||||
ManufacturerSection = HeapAlloc(GetProcessHeap(), 0, RequiredSize * sizeof(WCHAR));
|
ManufacturerSection = HeapAlloc(GetProcessHeap(), 0, RequiredSize * sizeof(WCHAR));
|
||||||
if (!ManufacturerSection)
|
if (!ManufacturerSection)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1523,13 +1523,13 @@ BOOL WINAPI SetupGetLineTextW( PINFCONTEXT context, HINF hinf, PCWSTR section_na
|
||||||
total += PARSER_string_substW( file, field->text, NULL, 0 ) + 1;
|
total += PARSER_string_substW( file, field->text, NULL, 0 ) + 1;
|
||||||
|
|
||||||
if (required) *required = total;
|
if (required) *required = total;
|
||||||
|
if (buffer)
|
||||||
|
{
|
||||||
if (total > size)
|
if (total > size)
|
||||||
{
|
{
|
||||||
SetLastError( ERROR_INSUFFICIENT_BUFFER );
|
SetLastError( ERROR_INSUFFICIENT_BUFFER );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (buffer)
|
|
||||||
{
|
|
||||||
for (i = 0, field = &file->fields[line->first_field]; i < line->nb_fields; i++, field++)
|
for (i = 0, field = &file->fields[line->first_field]; i < line->nb_fields; i++, field++)
|
||||||
{
|
{
|
||||||
unsigned int len = PARSER_string_substW( file, field->text, buffer, size );
|
unsigned int len = PARSER_string_substW( file, field->text, buffer, size );
|
||||||
|
@ -1574,13 +1574,13 @@ BOOL WINAPI SetupGetLineTextA( PINFCONTEXT context, HINF hinf, PCSTR section_nam
|
||||||
total += PARSER_string_substA( file, field->text, NULL, 0 ) + 1;
|
total += PARSER_string_substA( file, field->text, NULL, 0 ) + 1;
|
||||||
|
|
||||||
if (required) *required = total;
|
if (required) *required = total;
|
||||||
|
if (buffer)
|
||||||
|
{
|
||||||
if (total > size)
|
if (total > size)
|
||||||
{
|
{
|
||||||
SetLastError( ERROR_INSUFFICIENT_BUFFER );
|
SetLastError( ERROR_INSUFFICIENT_BUFFER );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (buffer)
|
|
||||||
{
|
|
||||||
for (i = 0, field = &file->fields[line->first_field]; i < line->nb_fields; i++, field++)
|
for (i = 0, field = &file->fields[line->first_field]; i < line->nb_fields; i++, field++)
|
||||||
{
|
{
|
||||||
unsigned int len = PARSER_string_substA( file, field->text, buffer, size );
|
unsigned int len = PARSER_string_substA( file, field->text, buffer, size );
|
||||||
|
@ -1619,13 +1619,13 @@ BOOL WINAPI SetupGetStringFieldA( PINFCONTEXT context, DWORD index, PSTR buffer,
|
||||||
if (!field) return FALSE;
|
if (!field) return FALSE;
|
||||||
len = PARSER_string_substA( file, field->text, NULL, 0 );
|
len = PARSER_string_substA( file, field->text, NULL, 0 );
|
||||||
if (required) *required = len + 1;
|
if (required) *required = len + 1;
|
||||||
|
if (buffer)
|
||||||
|
{
|
||||||
if (size <= len)
|
if (size <= len)
|
||||||
{
|
{
|
||||||
SetLastError( ERROR_INSUFFICIENT_BUFFER );
|
SetLastError( ERROR_INSUFFICIENT_BUFFER );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (buffer)
|
|
||||||
{
|
|
||||||
PARSER_string_substA( file, field->text, buffer, size );
|
PARSER_string_substA( file, field->text, buffer, size );
|
||||||
|
|
||||||
TRACE( "context %p/%p/%d/%d index %ld returning %s\n",
|
TRACE( "context %p/%p/%d/%d index %ld returning %s\n",
|
||||||
|
@ -1650,13 +1650,13 @@ BOOL WINAPI SetupGetStringFieldW( PINFCONTEXT context, DWORD index, PWSTR buffer
|
||||||
if (!field) return FALSE;
|
if (!field) return FALSE;
|
||||||
len = PARSER_string_substW( file, field->text, NULL, 0 );
|
len = PARSER_string_substW( file, field->text, NULL, 0 );
|
||||||
if (required) *required = len + 1;
|
if (required) *required = len + 1;
|
||||||
|
if (buffer)
|
||||||
|
{
|
||||||
if (size <= len)
|
if (size <= len)
|
||||||
{
|
{
|
||||||
SetLastError( ERROR_INSUFFICIENT_BUFFER );
|
SetLastError( ERROR_INSUFFICIENT_BUFFER );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (buffer)
|
|
||||||
{
|
|
||||||
PARSER_string_substW( file, field->text, buffer, size );
|
PARSER_string_substW( file, field->text, buffer, size );
|
||||||
|
|
||||||
TRACE( "context %p/%p/%d/%d index %ld returning %s\n",
|
TRACE( "context %p/%p/%d/%d index %ld returning %s\n",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue