[PATCH 1/8] xfsprogs: Fix setbitval() bug when nbits is byte-aligned
Alex Elder
aelder at sgi.com
Thu Nov 10 14:35:11 CST 2011
From: Kevan Rehm <kfr at sgi.com>
If a field whose size is not an even multiple of 8 bits happens to
be aligned on a byte boundary and the machine is little-endian,
routine setbitval() would do a byte copy of zero bytes, effectively
doing nothing.
Catch this case, and arrange for doing the bit setting "the hard
way" (i.e., without using memcpy()) to avoid this problem.
Signed-off-by: Alex Elder <aelder at sgi.com>
---
db/bit.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/db/bit.c b/db/bit.c
index ca57d31..36de0a1 100644
--- a/db/bit.c
+++ b/db/bit.c
@@ -153,7 +153,7 @@ setbitval(
*/
/* byte aligned ? */
- if (bitoff%NBBY) {
+ if (bitoff % NBBY || nbits % NBBY) {
/* no - bit copy */
for (bit=0; bit<nbits; bit++)
setbit(out, bit+bitoff, getbit(in, bit));
--
1.7.6.4
More information about the xfs
mailing list