diff options
author | Matt Turner <[email protected]> | 2017-11-23 10:41:34 -0800 |
---|---|---|
committer | Matt Turner <[email protected]> | 2017-11-25 12:30:46 -0800 |
commit | c690a7a8cdfb6425547bbb782020098405851194 (patch) | |
tree | 707101df33c8cc55f58acaf20b62f8a2cf867c55 /doxygen/header.html | |
parent | 513d7ffa23d42e96f831148fa13bf470087424c3 (diff) |
util: Fix disk_cache index calculation on big endian
The cache-test test program attempts to create a collision (using key_a
and key_a_collide) by making the first two bytes identical. The idea is
fine -- the shader cache wants to use the first four characters of a
SHA1 hex digest as the index.
The following program
unsigned char array[4] = {1, 2, 3, 4};
int *ptr = (int *)array;
for (int i = 0; i < 4; i++) {
printf("%02x", array[i]);
}
printf("\n");
printf("%08x\n", *ptr);
prints
01020304
04030201
on little endian, and
01020304
01020304
on big endian.
On big endian platforms reading the character array back as an int (as
is done in disk_cache.c) does not yield the same results as reading the
byte array.
To get the first four characters of the SHA1 hex digest when we mask
with CACHE_INDEX_KEY_MASK, we need to byte swap the int on big endian
platforms.
Bugzilla: https://bugs.freedesktop.org/103668
Bugzilla: https://bugs.gentoo.org/637060
Bugzilla: https://bugs.gentoo.org/636326
Fixes: 87ab26b2ab35 ("glsl: Add initial functions to implement an
on-disk cache")
Reviewed-by: Emil Velikov <[email protected]>
Diffstat (limited to 'doxygen/header.html')
0 files changed, 0 insertions, 0 deletions