From 4fc08d8fc29a99786f86896986d8912b03bc3c12 Mon Sep 17 00:00:00 2001 From: Arne Welzel Date: Wed, 7 Feb 2024 20:09:51 +0100 Subject: [PATCH] digest/digest_print: Use bytetohex() instead of snprintf() --- src/digest.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/digest.h b/src/digest.h index 61b063742e..da910a4f96 100644 --- a/src/digest.h +++ b/src/digest.h @@ -7,6 +7,7 @@ #pragma once #include // for u_char +#include #include #include @@ -41,7 +42,8 @@ enum HashAlgorithm { Hash_MD5, Hash_SHA1, Hash_SHA224, Hash_SHA256, Hash_SHA384, inline const char* digest_print(const u_char* digest, size_t n) { static char buf[ZEEK_DIGEST_PRINT_LENGTH]; for ( size_t i = 0; i < n; ++i ) - snprintf(buf + i * 2, 3, "%02x", digest[i]); + zeek::util::bytetohex(digest[i], &buf[i * 2]); + buf[2 * n] = '\0'; return buf; }