mirror of
https://github.com/ipxe/ipxe
synced 2026-07-02 20:10:19 +03:00
[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:
@@ -388,7 +388,9 @@ struct peerdist_info_segment {
|
||||
* 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 {
|
||||
|
||||
+1
-1
@@ -106,7 +106,7 @@ static void peerdist_info_segment_hash ( struct peerdist_info_segment *segment,
|
||||
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 ) );
|
||||
|
||||
Reference in New Issue
Block a user