Skip to content

util: Pass buffer to SHA1Transform by reference

David Heidelberg requested to merge dh/mesa:sha1-fixup into main

Instead of as a 64-byte value. This might be more efficient, and avoids GCC complaining that initializing the 64-byte parameter value reads beyond the end of the apparent 1-byte value (uint8_t *) in SHA1Update:

In function 'SHA1Update',
    inlined from 'SHA1Pad' at ../src/util/sha1/sha1.c:157:2,
    inlined from 'SHA1Final' at ../src/util/sha1/sha1.c:168:2,
    inlined from '_mesa_sha1_final' at ../src/util/mesa-sha1.h:53:4,
    inlined from '_mesa_sha1_compute' at ../src/util/mesa-sha1.c:39:4,
    inlined from 'parseAppAttr' at ../src/util/xmlconfig.c:731:13:
../src/util/sha1/sha1.c:135:25: warning: 'SHA1Transform' reading 64 bytes from a region of size 1 [-Wstringop-overread]
  135 |                         SHA1Transform(context->state, (uint8_t *)&data[i]);
      |                         ^
../src/util/sha1/sha1.c:135:25: note: referencing argument 2 of type 'const uint8_t[64]'
../src/util/sha1/sha1.c: In function 'parseAppAttr':
../src/util/sha1/sha1.c:55:1: note: in a call to function 'SHA1Transform'
   55 | SHA1Transform(uint32_t state[5], const uint8_t buffer[SHA1_BLOCK_LENGTH])
      | ^

Feel free to propose better solution, or I would be inclined to merge this. Debian 12 CI uprev (because of GCC 12) update depends on it.

Merge request reports