From b68666dc6b93307a6244321e1acee5b58f63c6ff Mon Sep 17 00:00:00 2001 From: speedie Date: Fri, 9 Jun 2023 21:20:02 +0200 Subject: [PATCH] No longer use deprecated MD5() function to get hash --- libs/img.c | 16 ++++++++++++---- libs/img.h | 2 +- meson.build | 1 - 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/libs/img.c b/libs/img.c index 4d7708d..6957113 100644 --- a/libs/img.c +++ b/libs/img.c @@ -211,8 +211,8 @@ void scaleimage(int *width, int *height) { void loadimagecache(const char *file, int *width, int *height) { int slen = 0, i; - unsigned char digest[MD5_DIGEST_LENGTH]; - char md5[MD5_DIGEST_LENGTH*2+1]; + unsigned int digest_len = EVP_MD_size(EVP_md5()); + unsigned char *digest = (unsigned char *)OPENSSL_malloc(digest_len); char *xdg_cache, *home = NULL, *dsize, *buf = NULL; struct passwd *pw = NULL; @@ -249,11 +249,19 @@ void loadimagecache(const char *file, int *width, int *height) { // calculate md5 from path sprintf(buf, "file://%s", file); - MD5((unsigned char*)buf, slen, digest); + + EVP_MD_CTX *mdcontext = EVP_MD_CTX_new(); + EVP_DigestInit_ex(mdcontext, EVP_md5(), NULL); + EVP_DigestUpdate(mdcontext, buf, slen); + + EVP_DigestFinal_ex(mdcontext, digest, &digest_len); + EVP_MD_CTX_free(mdcontext); free(buf); - for(i = 0; i < MD5_DIGEST_LENGTH; ++i) + char md5[digest_len*2+1]; + + for (i = 0; i < digest_len; ++i) sprintf(&md5[i*2], "%02x", (unsigned int)digest[i]); // path for cached thumbnail diff --git a/libs/img.h b/libs/img.h index 399a8e3..1d2326f 100644 --- a/libs/img.h +++ b/libs/img.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include static void setimagesize(int width, int height); static void setimageopts(void); diff --git a/meson.build b/meson.build index 9cd9721..0d32938 100644 --- a/meson.build +++ b/meson.build @@ -31,7 +31,6 @@ build_args = [ '-std=c99', '-pedantic', '-Wall', - '-Wno-deprecated-declarations', '-Wno-unused-parameter', '-Wno-sign-compare', ]