[Pkg-alsa-devel] Bug#323331: [patch] ld10k1 not 64bit clean.

Zephaniah E. Hull warp at babylon.d2dc.net
Tue Aug 16 03:37:31 UTC 2005


Package: ld10k1
Version: 1.0.9-1
Severity: grave
Tags: patch, upstream

On all 64bit systems (the easiest example is amd64) ld10k1 crashes on
use by lo10k1, some debugging tracked down the problem fairly quickly.

The bitops functions (set_bit and associated) that ld10k1 use come from
the linux kernel, and assume that longs are 32bit only, causing a buffer
overflow of the bit buffer.

The attached patch fixes the bitops to be independent of the size of
longs, and is confirmed to fix the bug on my box.

Zephaniah E. Hull.
-------------- next part --------------
diff -ur alsa-tools-1.0.9/ld10k1/src/bitops.h alsa-tools-1.0.9.mine/ld10k1/src/bitops.h
--- alsa-tools-1.0.9/ld10k1/src/bitops.h	2005-03-18 08:41:02.000000000 -0500
+++ alsa-tools-1.0.9.mine/ld10k1/src/bitops.h	2005-08-15 23:24:46.000000000 -0400
@@ -15,13 +15,17 @@
  * 
  * C language equivalents written by Theodore Ts'o, 9/26/92
  */
+/*
+ * Converted to be independent of the size of longs.
+ * Zephaniah E. Hull 2005-08-15.
+ */
 
 __inline__ int set_bit(int nr, unsigned long * addr)
 {
 	int	mask, retval;
 
-	addr += nr >> 5;
-	mask = 1 << (nr & 0x1f);
+	addr += nr >> (sizeof(long) + 1);
+	mask = 1 << (nr & (sizeof(long) * 8 - 1));
 	retval = (mask & *addr) != 0;
 	*addr |= mask;
 	return retval;
@@ -31,8 +35,8 @@
 {
 	int	mask, retval;
 
-	addr += nr >> 5;
-	mask = 1 << (nr & 0x1f);
+	addr += nr >> (sizeof(long) + 1);
+	mask = 1 << (nr & (sizeof(long) * 8 - 1));
 	retval = (mask & *addr) != 0;
 	*addr &= ~mask;
 	return retval;
@@ -42,8 +46,8 @@
 {
 	int	mask;
 
-	addr += nr >> 5;
-	mask = 1 << (nr & 0x1f);
+	addr += nr >> (sizeof(long) + 1);
+	mask = 1 << (nr & (sizeof(long) * 8 - 1));
 	return ((mask & *addr) != 0);
 }
 


More information about the Pkg-alsa-devel mailing list