[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>
diff --git a/src/include/ipxe/pccrc.h b/src/include/ipxe/pccrc.h index 6d0e3f1..61f5d0b 100644 --- a/src/include/ipxe/pccrc.h +++ b/src/include/ipxe/pccrc.h
@@ -388,7 +388,9 @@ * ASCII string. The terminating wNUL *is* included within the * 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 */ struct peerdist_info_block {
diff --git a/src/net/pccrc.c b/src/net/pccrc.c index 4bf2f44..7ee6afe 100644 --- a/src/net/pccrc.c +++ b/src/net/pccrc.c
@@ -106,7 +106,7 @@ struct digest_algorithm *digest = info->digest; uint8_t ctx[ hmac_ctxsize ( digest ) ]; 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 */ assert ( digestsize <= sizeof ( segment->hash ) );