fix: correct reading for hash function
This commit is contained in:
parent
839bcb47bf
commit
5cdb857988
2
Makefile
2
Makefile
@ -9,7 +9,7 @@ SRCS = $(wildcard src/*.c) $(wildcard src/*/*.c)
|
||||
OBJS = $(patsubst src/%.c,dist/%.o,$(SRCS))
|
||||
HDRS = $(wildcard include/*.h)
|
||||
CFLAGS = -O3 -fstack-protector-strong -fcf-protection=full -fstack-clash-protection
|
||||
LIBS = -lpthread -larchive -linih -lgpgme -lsqlite3
|
||||
LIBS = -lpthread -lcrypto -larchive -linih -lgpgme -lsqlite3
|
||||
|
||||
DEBUG = 0
|
||||
VERSION = 24.00
|
||||
|
@ -10,6 +10,7 @@ it from the source and install it.
|
||||
To this you will need the following tools and libraries:
|
||||
- gcc
|
||||
- make
|
||||
- openssl
|
||||
- libarchive
|
||||
- libinih
|
||||
- gettext
|
||||
|
@ -17,6 +17,11 @@ int main(int argc, char *argv[]) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!mkdir_ifnot(ROOT_DIR)) {
|
||||
printf("failed to create root dir: %s\n", ROOT_DIR);
|
||||
return ret;
|
||||
}
|
||||
|
||||
lm_ctx_init(&ctx);
|
||||
|
||||
if (!lm_ctx_set_data(&ctx, DATA_DIR)) {
|
||||
@ -24,6 +29,11 @@ int main(int argc, char *argv[]) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!lm_ctx_set_root(&ctx, ROOT_DIR)) {
|
||||
printf("failed to set root dir: %s (%d)\n", lm_strerror(), lm_error());
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!lm_ctx_database_find(&ctx, &pkg, argv[1], NULL)) {
|
||||
printf("failed to find package: %s (%d)\n", lm_strerror(), lm_error());
|
||||
goto end;
|
||||
@ -36,6 +46,8 @@ int main(int argc, char *argv[]) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
printf("package check was successful!\n");
|
||||
|
||||
ret = EXIT_SUCCESS;
|
||||
|
||||
end:
|
||||
|
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2024-07-11 07:30+0300\n"
|
||||
"POT-Creation-Date: 2024-07-11 07:49+0300\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -31,6 +31,8 @@ bool lm_ctx_check(lm_ctx_t *ctx, lm_pkg_t *pkg, lm_ctx_check_callback_t callback
|
||||
join(fp, ctx->root, path);
|
||||
current++;
|
||||
|
||||
pdebug(__func__, "(%d/%d) checking %s", current, total, fp);
|
||||
|
||||
if(NULL != callback)
|
||||
if(!callback(ctx, pkg, fp, current, total, data))
|
||||
goto end;
|
||||
|
@ -248,13 +248,15 @@ void lm_database_files_next_free(lm_database_t *db, lm_pkg_t *pkg, char **path,
|
||||
return;
|
||||
}
|
||||
|
||||
if(NULL != db->files_st)
|
||||
if(NULL != db->files_st){
|
||||
sqlite3_finalize(db->files_st);
|
||||
db->files_st = NULL;
|
||||
}
|
||||
|
||||
if(NULL == *path)
|
||||
if(NULL != path)
|
||||
free(*path);
|
||||
|
||||
if(NULL == *hash)
|
||||
if(NULL != hash)
|
||||
free(*hash);
|
||||
|
||||
*keep = false;
|
||||
|
@ -447,6 +447,7 @@ char *get_md5(char *path) {
|
||||
size_t read = 0;
|
||||
|
||||
alg = EVP_md5();
|
||||
ctx = EVP_MD_CTX_new();
|
||||
bzero(buffer, sizeof(buffer));
|
||||
bzero(digest, sizeof(digest));
|
||||
|
||||
@ -460,7 +461,7 @@ char *get_md5(char *path) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while ((read = fread(buffer, sizeof(buffer), 1, file)) > 0)
|
||||
while ((read = fread(buffer, 1, sizeof(buffer), file)) > 0)
|
||||
EVP_DigestUpdate(ctx, buffer, read);
|
||||
|
||||
EVP_DigestFinal(ctx, digest, &digest_len);
|
||||
@ -469,7 +470,8 @@ char *get_md5(char *path) {
|
||||
sum = malloc((digest_len * 2) + 1);
|
||||
|
||||
for (int i = 0; i < sizeof(digest); i++)
|
||||
sprintf(&sum[i * 2], "%02x", (unsigned int)digest[i]);
|
||||
sprintf(&sum[i * 2], "%02x", digest[i]);
|
||||
|
||||
fclose(file);
|
||||
return sum;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user