1
0
Fork 0
mirror of synced 2025-03-07 03:53:26 +01:00

msi: Round costs up to 4096 bytes instead of clamping.

This commit is contained in:
Zebediah Figura 2024-03-02 15:06:31 -06:00 committed by Alexandre Julliard
parent 674efeb1f7
commit 9725a2286a
3 changed files with 10 additions and 3 deletions

View file

@ -2037,14 +2037,14 @@ UINT WINAPI MsiEnumComponentCostsW( MSIHANDLE handle, const WCHAR *component, DW
}
else if ((file = msi_get_loaded_file( package, comp->KeyPath )))
{
*cost = max( 8, comp->Cost / 512 );
*cost = cost_from_size( comp->Cost );
*buflen = set_drive( drive, file->TargetPath[0] );
r = ERROR_SUCCESS;
}
}
else if (IStorage_Stat( package->db->storage, &stat, STATFLAG_NONAME ) == S_OK)
{
*temp = max( 8, stat.cbSize.QuadPart / 512 );
*temp = cost_from_size( stat.cbSize.QuadPart );
*buflen = set_drive( drive, path[0] );
r = ERROR_SUCCESS;
}

View file

@ -1194,4 +1194,11 @@ static inline LPWSTR strdupUtoW( LPCSTR str )
return ret;
}
static inline int cost_from_size( int size )
{
/* Cost is size rounded up to the nearest 4096 bytes,
* expressed in units of 512 bytes. */
return ((size + 4095) & ~4095) / 512;
}
#endif /* __WINE_MSI_PRIVATE__ */

View file

@ -8628,7 +8628,7 @@ static void test_costs(void)
ok( len == 2, "expected len == 2, got %lu\n", len );
ok( drive[0], "expected a drive\n" );
ok( !cost, "expected cost == 0, got %d\n", cost );
ok( temp && temp != 0xdead, "expected temp > 0, got %d\n", temp );
todo_wine ok( temp && temp != 0xdead, "expected temp > 0, got %d\n", temp );
/* increased index */
len = sizeof(drive);