diff options
Diffstat (limited to 'modified.c')
-rw-r--r-- | modified.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -6,7 +6,7 @@ bool user_modified(char *file) { char *filedump = NULL; size_t len = 0, len2 = 0; char *md5sum; - char filemd5[MD5_DIGEST_LENGTH]; + unsigned char filemd5[MD5_DIGEST_LENGTH]; char hexdigest[32]; bool user_mod = TRUE; if (access(MD5SUM_INDEX, R_OK) != 0) { @@ -20,7 +20,7 @@ bool user_modified(char *file) { filepipe = fopen(file, "r"); exit_error(filepipe, file); if (getdelim(&filedump, &len2, EOF, filepipe) != -1) { - MD5(filedump, strlen(filedump), filemd5); + MD5((unsigned char *)filedump, strlen(filedump), filemd5); md52hex(filemd5, hexdigest); if (!strncmp(md5sum, hexdigest, 32)) { user_mod = FALSE; @@ -36,7 +36,7 @@ bool user_modified(char *file) { } } -void md52hex(char *md5sum, char *hexdigest) { +void md52hex(unsigned char *md5sum, char *hexdigest) { // this one is stolen from python's md5module.c char c; int i, j = 0; @@ -56,11 +56,11 @@ void calc_md5(char *file, char* hexdigest) { char *dump = NULL; size_t len = 0; - char md5sum[MD5_DIGEST_LENGTH]; + unsigned char md5sum[MD5_DIGEST_LENGTH]; fp = fopen(file, "r"); if (getdelim(&dump, &len, EOF, fp) != -1) { - MD5(dump, strlen(dump), md5sum); + MD5((unsigned char *)dump, strlen(dump), md5sum); md52hex(md5sum, hexdigest); free(dump); } @@ -72,11 +72,11 @@ void md5sum_update(char *file, char *hexdigest) { char *dump = NULL; size_t len = 0; char *entry; + oldpipe = fopen(MD5SUM_INDEX, "r"); exit_error(oldpipe, MD5SUM_INDEX); - getdelim(&dump, &len, EOF, oldpipe); - if ((entry = strstr(dump, file))) { + if ((getdelim(&dump, &len, EOF, oldpipe) != -1) && (entry = strstr(dump, file))) { entry = strchr(entry, '\n') - 32; strncpy(entry, hexdigest, 32); exit_error(freopen(MD5SUM_INDEX, "w", oldpipe), MD5SUM_INDEX); |