Commit Diff


commit - ae25a666dd4099105786ef32f1e6ebaf92abe64d
commit + 14f89e3e5394e931edf4581cfb229beef1de3f41
blob - b13fad65324a1d95a5dba98ac096ee6accce9093
blob + 0d02c860eaa1b48dbfe675e8d6987396d3a1ff21
--- lib/hash.c
+++ lib/hash.c
@@ -71,17 +71,15 @@ parse_digest(uint8_t *digest, int len, const char *lin
 static char *
 digest_to_str(const uint8_t *digest, int len, char *buf)
 {
+	const char hex[] = "0123456789abcdef";
 	char *p = buf;
-	char hex[3];
 	int i;
 
 	for (i = 0; i < len; i++) {
-		snprintf(hex, sizeof(hex), "%.2x", digest[i]);
-		p[0] = hex[0];
-		p[1] = hex[1];
-		p += 2;
+		*p++ = hex[digest[i] >> 4];
+		*p++ = hex[digest[i] & 0xf];
 	}
-	p[0] = '\0';
+	*p = '\0';
 
 	return buf;
 }