lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1209329003-22036-1-git-send-email-bert.wesarg@googlemail.com>
Date:	Sun, 27 Apr 2008 22:43:23 +0200
From:	Bert Wesarg <bert.wesarg@...glemail.com>
To:	mingo@...e.hu
Cc:	linux-kernel@...r.kernel.org, torvalds@...ux-foundation.org,
	akpm@...ux-foundation.org,
	Bert Wesarg <bert.wesarg@...glemail.com>,
	Mike Travis <travis@....com>, Paul Jackson <pj@....com>
Subject: [PATCH] Fix calculus of bitmap_scnprintf_len()

The function bitmap_scnprintf_len() is currently not used, but the returned
value is 4 times larger than needed. This value is also only a good upper
bound. Which should be mentioned in the comment.

The correct number of chars needed for the buffer, exluding any new line and
terminating zero is:

int bitmap_scnprintf_len(int len)
{
	return  /* complete hunks with commas */
	          ((len / CHUNKSZ) * 9)
	        /* partial hunk, 4 bits in one char */
	       + (((len % CHUNKSZ) + 3) / 4)
	        /* one less comma, if no partial hunk */
	       -  !(len % CHUNKSZ);
}

Signed-off-by: Bert Wesarg <bert.wesarg@...glemail.com>
Cc: Mike Travis <travis@....com>
Cc: Paul Jackson <pj@....com>

---
 lib/bitmap.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/bitmap.c b/lib/bitmap.c
index a6939e1..47e6f0f 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -325,7 +325,7 @@ int bitmap_scnprintf_len(unsigned int len)
 	/* we need 9 chars per word for 32 bit words (8 hexdigits + sep/null) */
 	int bitslen = ALIGN(len, CHUNKSZ);
 	int wordlen = CHUNKSZ / 4;
-	int buflen = (bitslen / wordlen) * (wordlen + 1) * sizeof(char);
+	int buflen = (bitslen / CHUNKSZ) * (wordlen + 1);
 
 	return buflen;
 }
-- 
1.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ