No longer use deprecated MD5() function to get hash
This commit is contained in:
parent
d6df27e839
commit
b68666dc6b
16
libs/img.c
16
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
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <errno.h>
|
||||
#include <pwd.h>
|
||||
#include <Imlib2.h>
|
||||
#include <openssl/md5.h>
|
||||
#include <openssl/evp.h>
|
||||
|
||||
static void setimagesize(int width, int height);
|
||||
static void setimageopts(void);
|
||||
|
|
|
@ -31,7 +31,6 @@ build_args = [
|
|||
'-std=c99',
|
||||
'-pedantic',
|
||||
'-Wall',
|
||||
'-Wno-deprecated-declarations',
|
||||
'-Wno-unused-parameter',
|
||||
'-Wno-sign-compare',
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue