[peerdist] Fix segment identifier constant on big-endian targets

The "MS_P2P_CACHING" constant (used as part of the HMAC digest
calculation for the segment identifier) is a UTF-16LE string.  On a
big-endian target, a wide-character string literal will have the wrong
endianness.

Fix by using a byte array rather than a wide-character string.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2026-06-13 16:03:33 +01:00
parent bfdbd1c4e0
commit 6476f7c7c5
2 changed files with 4 additions and 2 deletions
+3 -1
View File
@@ -388,7 +388,9 @@ struct peerdist_info_segment {
* ASCII string. The terminating wNUL *is* included within the * ASCII string. The terminating wNUL *is* included within the
* constant. * constant.
*/ */
#define PEERDIST_SEGMENT_ID_MAGIC L"MS_P2P_CACHING" #define PEERDIST_SEGMENT_ID_MAGIC \
{ 'M', 0, 'S', 0, '_', 0, 'P', 0, '2', 0, 'P', 0, '_', 0, \
'C', 0, 'A', 0, 'C', 0, 'H', 0, 'I', 0, 'N', 0, 'G', 0, 0, 0 }
/** A content information block */ /** A content information block */
struct peerdist_info_block { struct peerdist_info_block {
+1 -1
View File
@@ -106,7 +106,7 @@ static void peerdist_info_segment_hash ( struct peerdist_info_segment *segment,
struct digest_algorithm *digest = info->digest; struct digest_algorithm *digest = info->digest;
uint8_t ctx[ hmac_ctxsize ( digest ) ]; uint8_t ctx[ hmac_ctxsize ( digest ) ];
size_t digestsize = info->digestsize; size_t digestsize = info->digestsize;
static const uint16_t magic[] = PEERDIST_SEGMENT_ID_MAGIC; static const uint8_t magic[] = PEERDIST_SEGMENT_ID_MAGIC;
/* Sanity check */ /* Sanity check */
assert ( digestsize <= sizeof ( segment->hash ) ); assert ( digestsize <= sizeof ( segment->hash ) );