From edf518f1502594cd8656e5800797414b8a5fbe65 Mon Sep 17 00:00:00 2001 From: Hendrik Muhs Date: Mon, 19 Feb 2024 14:33:01 +0100 Subject: [PATCH] Fix warning about sprintf usage (#286) remove methods in question that produce the warning instead of fixing, because it is not used anyway. --- keyvi/3rdparty/misc/md5.h | 26 +------------------ .../tests/keyvi/dictionary/util/md5_test.cpp | 12 +++------ 2 files changed, 4 insertions(+), 34 deletions(-) diff --git a/keyvi/3rdparty/misc/md5.h b/keyvi/3rdparty/misc/md5.h index 8bc9acba1..1984d3a06 100644 --- a/keyvi/3rdparty/misc/md5.h +++ b/keyvi/3rdparty/misc/md5.h @@ -34,6 +34,7 @@ // The original md5 implementation avoids external libraries. // This version has dependency on stdio.h for file input and // string.h for memcpy. +#include #include #include @@ -317,36 +318,11 @@ class MD5 memset((POINTER)&context, 0, sizeof (context)); } - /// Buffer must be 32+1 (nul) = 33 chars long at least - void writeToString() - { - int pos ; - - for( pos = 0 ; pos < 16 ; pos++ ) - sprintf( digestChars+(pos*2), "%02x", digestRaw[pos] ) ; - } - public: // an MD5 digest is a 16-byte number (32 hex digits) BYTE digestRaw[ 16 ] ; - // This version of the digest is actually - // a "printf'd" version of the digest. - char digestChars[ 33 ] ; - - // Digests a string and prints the result. - char* digestString( const char *string ) - { - Init() ; - Update( (unsigned char*)string, strlen(string) ) ; - Final() ; - - writeToString() ; - - return digestChars ; - } - uint64_t Hash( const char * string ) { Init(); diff --git a/keyvi/tests/keyvi/dictionary/util/md5_test.cpp b/keyvi/tests/keyvi/dictionary/util/md5_test.cpp index f988abbf3..c178bdabf 100644 --- a/keyvi/tests/keyvi/dictionary/util/md5_test.cpp +++ b/keyvi/tests/keyvi/dictionary/util/md5_test.cpp @@ -23,22 +23,19 @@ * Author: hendrik */ +#include "md5.h" #include -#include "md5.h" - namespace keyvi { namespace dictionary { namespace util { -BOOST_AUTO_TEST_SUITE( MD5Tests ) +BOOST_AUTO_TEST_SUITE(MD5Tests) -BOOST_AUTO_TEST_CASE( MD5HashTest ) { +BOOST_AUTO_TEST_CASE(MD5HashTest) { misc::MD5 m = misc::MD5(); - BOOST_CHECK_EQUAL(m.digestString("test"), "098f6bcd4621d373cade4e832627b4f6"); - BOOST_CHECK_EQUAL(14618207765679027446U, m.Hash("test")); BOOST_CHECK_EQUAL(13339385412431753948U, m.Hash("MYKEY")); BOOST_CHECK_EQUAL(16825458760271544958U, m.Hash("")); @@ -46,11 +43,8 @@ BOOST_AUTO_TEST_CASE( MD5HashTest ) { BOOST_CHECK_EQUAL(13356017483753479679U, m.Hash("-------------------------------------")); } - BOOST_AUTO_TEST_SUITE_END() } /* namespace util */ } /* namespace dictionary */ } /* namespace keyvi */ - -