| To: | xfs@xxxxxxxxxxx |
|---|---|
| Subject: | [PATCH 1/8] xfsprogs: Fix setbitval() bug when nbits is byte-aligned |
| From: | Alex Elder <aelder@xxxxxxx> |
| Date: | Thu, 10 Nov 2011 14:35:11 -0600 |
| Cc: | Kevan Rehm <kfr@xxxxxxx>, Alex Elder <aelder@xxxxxxx> |
| In-reply-to: | <1320957318-16269-1-git-send-email-aelder@xxxxxxx> |
| References: | <1320957318-16269-1-git-send-email-aelder@xxxxxxx> |
From: Kevan Rehm <kfr@xxxxxxx>
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@xxxxxxx>
---
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
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | [PATCH 0/8] xfsprogs: new resvsp db command, plus some fixes, Alex Elder |
|---|---|
| Next by Date: | [PATCH 2/8] xfsprogs: unconditionally drop used buffer reference, Alex Elder |
| Previous by Thread: | [PATCH 0/8] xfsprogs: new resvsp db command, plus some fixes, Alex Elder |
| Next by Thread: | [PATCH 2/8] xfsprogs: unconditionally drop used buffer reference, Alex Elder |
| Indexes: | [Date] [Thread] [Top] [All Lists] |