[PATCH 1/8] xfsprogs: Fix setbitval() bug when nbits is byte-aligned

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

_______________________________________________
xfs mailing list
xfs@xxxxxxxxxxx
http://oss.sgi.com/mailman/listinfo/xfs


[Index of Archives]     [Linux XFS Devel]     [Linux Filesystem Development]     [Filesystem Testing]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux