Subject: lib/12496: sha1(3) has a typo in an example
To: None <gnats-bugs@gnats.netbsd.org>
From: None <jbernard@mines.edu>
List: netbsd-bugs
Date: 03/28/2001 16:15:41
>Number:         12496
>Category:       lib
>Synopsis:       sha1(3) has a typo in an example
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    lib-bug-people
>State:          open
>Class:          doc-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Mar 28 15:16:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Jim Bernard
>Release:        March 28, 2001
>Organization:
>Environment:
System: NetBSD knox 1.5S NetBSD 1.5S (KNOX-$Revision: 1.14 $) #0: Thu Mar 15 11:09:03 MST 2001 jbernard@knox:/fh/home/tmp/compile/sys/arch/sparc/compile/KNOX sparc
Architecture: sparc
Machine: sparc
>Description:
	In the examples section, the digest is printed via:

	  for (n = 0; n < 20; n++)
	      printf("%x", results[n]);

	Of course, this would omit leading zeros from bytes that should
	have them.  A "%02x" format should be used to get the full digest.

>How-To-Repeat:

>Fix:
	Patch to .../lib/libc/hash/sha1.3:

--- sha1.3-dist	Fri Jan 19 08:54:36 2001
+++ sha1.3	Wed Mar 28 16:06:17 2001
@@ -166,11 +166,11 @@
 SHA1Final(results, &sha);
 
 /* Print the digest as one long hex value */
 printf("0x");
 for (n = 0; n < 20; n++)
-	printf("%x", results[n]);
+	printf("%02x", results[n]);
 putchar('\\n');
 .Ed
 .Pp
 Alternately, the helper functions could be used in the following way:
 .Bd -literal -offset indent
>Release-Note:
>Audit-Trail:
>Unformatted: