Skip to content
Fossil Update of ”checkin/384705b56ac5adb3e33ecbc5a4dd8e33393caed8b96f02afbb7799667afffe07”
Login

Update of ”checkin/384705b56ac5adb3e33ecbc5a4dd8e33393caed8b96f02afbb7799667afffe07”

Overview

Artifact ID: 37a36941653160f253668c83072c569d64fd889475a5feff5f7a8c421fdafb74
Page Name:checkin/384705b56ac5adb3e33ecbc5a4dd8e33393caed8b96f02afbb7799667afffe07
Date: 2026-11-21 13:02:07
Original User: stephan
Mimetype:text/x-markdown
Content

SHA1 hashes wrong on big-endian hosts

Symptom

On a big-endian host (reported on a PowerPC iBook), fossil update in both the SQLite and Fossil repositories aborted with:

hash of rid 19096 does not match its uuid (
Abort trap

That message comes from verify_rid() in src/verify.c. Every artifact gets checked against its stored hash before a commit, and this one failed.

Cause

The cause is check-in [d243deba6a] (2026-10-16), which updated src/sha1hard.c to the current upstream sha1dc code.

SHA1 reads its input as big-endian 32-bit words. Little-endian hosts have to byte-swap each word, and big-endian hosts must not. The previous sha1hard.c checked the host byte order at runtime (ctx->bigendian) and skipped the swap on big-endian hosts. The updated code makes that choice at compile time instead:

#if defined(BIGENDIAN)
  #define sha1_load(m, t) (m[t])
#else
  #define sha1_load(m, t, temp)  { temp = m[t]; sha1_bswap32(temp); }
#endif

That code has two defects:

  1. Nothing in the build defines BIGENDIAN, so every platform takes the byte-swapping branch. Upstream sha1dc decides this with a large block of SHA1DC_BIGENDIAN detection, which didn't come over in the update.
  2. The big-endian branch couldn't have compiled anyway. Its macro takes two arguments, but its only caller passes three.

The result is that every SHA1 hash computed on a big-endian host is wrong. The first SHA1-named artifact that gets checked fails in verify_rid(). SHA3 hashing doesn't use this code and isn't affected. That's why the failure shows up as a hash mismatch on older artifacts instead of some more general breakage.

Fix

All of the changes are in src/sha1hard.c:

Testing Performed

Note for affected installations

A big-endian build from between [d243deba6a] and this fix computes wrong SHA1 hashes. Because the check before each commit aborts the operation, it's unlikely that bad data was stored. Even so, it would be worth running fossil test-integrity with a fixed build on any repositories that such a binary used.