1
0
mirror of https://github.com/openbsd/src.git synced 2026-04-30 09:06:11 +00:00

Don't typecast cg_meta to uint8_t * and access it like an array. This is

not endian safe and breaks on big endian systems. Found the hard way by
denis@. Instead use the same shit and mask operations as used in the
other functions operating on cg_meta.
OK denis@
This commit is contained in:
claudio
2025-11-22 16:14:56 +00:00
parent d1bc7a3968
commit bd79ebde54

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: chash.c,v 1.5 2025/11/21 12:19:00 claudio Exp $ */
/* $OpenBSD: chash.c,v 1.6 2025/11/22 16:14:56 claudio Exp $ */
/*
* Copyright (c) 2025 Claudio Jeker <claudio@openbsd.org>
*
@@ -121,9 +121,13 @@ cg_meta_check_flags(const struct ch_group *g, uint8_t flag)
}
static inline void
cg_meta_set_hash(struct ch_group *g, int slot, uint8_t hash)
cg_meta_set_hash(struct ch_group *g, int slot, uint64_t hash)
{
((uint8_t *)&g->cg_meta)[slot] = hash;
uint64_t newval;
newval = g->cg_meta & ~(0xffULL << (slot * 8));
newval |= hash << (slot * 8);
g->cg_meta = newval;
}
/*