This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository efl.
View the commit online.
commit 1905320c5c5a72c138391ea5708efd40577305a5
Author: Cedric BAIL <[email protected]>
AuthorDate: Sun Nov 15 22:37:27 2026 -0600
eina: eina_crc reads the bytes after the 8 byte steps as unsigned
The bytes left over after the 8 byte steps were read through a plain
char, which is signed on most targets: a byte of 0x80 or above became
a negative int, and xored with the crc it indexed far outside the
256 entry table. The result was garbage at best and a crash at worst.
The ector software renderers hash binary state (doubles, colours,
pointers) with eina_crc for their caches, so they hit this all the
time. The values are only kept in memory, so no stored crc changes.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
src/lib/eina/eina_crc.c | 2 +-
src/tests/eina/eina_test_crc.c | 15 +++++++++++++++
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/src/lib/eina/eina_crc.c b/src/lib/eina/eina_crc.c
index 616d07931c..68e46dd908 100644
--- a/src/lib/eina/eina_crc.c
+++ b/src/lib/eina/eina_crc.c
@@ -312,7 +312,7 @@ _eina_crc(const char *data, int len, unsigned int seed, Eina_Bool start_stream)
len -= 8;
}
- const char* currChar = (char*) curr;
+ const unsigned char *currChar = (const unsigned char *)curr;
while (len--)
crc = (crc >> 8) ^ table[0][(crc & 0xFF) ^ *currChar++];
diff --git a/src/tests/eina/eina_test_crc.c b/src/tests/eina/eina_test_crc.c
index d187073e1e..87f1db204f 100644
--- a/src/tests/eina/eina_test_crc.c
+++ b/src/tests/eina/eina_test_crc.c
@@ -45,7 +45,22 @@ EFL_START_TEST(eina_crc_simple)
}
EFL_END_TEST
+/* Bytes of 0x80 and above, in the bytes left after the 8 byte steps: the
+ * values are those of zlib's crc32(). */
+EFL_START_TEST(eina_crc_high_bytes)
+{
+ const char short_data[] = "\x80\xff\xa9";
+ const char long_data[] = "eina \xc3\xa9t\xc3\xa9 \xff\x80\xfe";
+
+ ck_assert_uint_eq(eina_crc(short_data, sizeof(short_data) - 1, 0xffffffff, EINA_TRUE),
+ 0x225a24ac);
+ ck_assert_uint_eq(eina_crc(long_data, sizeof(long_data) - 1, 0xffffffff, EINA_TRUE),
+ 0xf6cfc767);
+}
+EFL_END_TEST
+
void eina_test_crc(TCase *tc)
{
tcase_add_test(tc, eina_crc_simple);
+ tcase_add_test(tc, eina_crc_high_bytes);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.