Michael Gold | 19 Aug 2004 22:43
Favicon

[PATCH] Fix for memory allocation in fingerprint.c

This patch fixes an off-by-one memory allocation error in the
printable_fingerprint function of lib/fingerprint.c. The code
sprintf((char *)p, "%02X ", fp[i]); prints a space and terminating null
byte on every call, but no memory was reserved for the null byte.

- Michael
diff -urN openscep-0.4.2-orig/lib/fingerprint.c openscep-0.4.2/lib/fingerprint.c
--- openscep-0.4.2-orig/lib/fingerprint.c	2002-02-19 18:40:06.000000000 -0500
+++ openscep-0.4.2/lib/fingerprint.c	2004-08-19 13:04:16.000000000 -0400
 <at>  <at>  -45,7 +45,7  <at>  <at> 
 	int		i;

 	/* prepare a printable version of the fingerprint		*/
-	rp = (unsigned char *)malloc(2 * MD5_DIGEST_LENGTH + 1 + fp_blanks * 3);
+	rp = (unsigned char *)malloc(2 * MD5_DIGEST_LENGTH + 2 + fp_blanks * 3);
 	p = rp;
 	for (i = 0; i < MD5_DIGEST_LENGTH; i++, p += 2) {
 		if (fp_blanks)

Gmane