aboutsummaryrefslogtreecommitdiffstats
path: root/src/r-gpgme.c
diff options
context:
space:
mode:
authorJoursoir <chat@joursoir.net>2021-03-23 17:32:33 +0000
committerJoursoir <chat@joursoir.net>2021-03-23 17:32:33 +0000
commite06f9fcb689878878469e2396617786ed525ca87 (patch)
tree1efd4748996de665c01595464cb7f40ab9a7618a /src/r-gpgme.c
parentf14b09b10db42962a4f7f0a4d7f9cf2ea8feef4f (diff)
downloadlock-password-e06f9fcb689878878469e2396617786ed525ca87.tar.gz
lock-password-e06f9fcb689878878469e2396617786ed525ca87.tar.bz2
lock-password-e06f9fcb689878878469e2396617786ed525ca87.zip
refactor; set correct headers guard
Diffstat (limited to 'src/r-gpgme.c')
-rw-r--r--src/r-gpgme.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/r-gpgme.c b/src/r-gpgme.c
index a13a62a..586bd55 100644
--- a/src/r-gpgme.c
+++ b/src/r-gpgme.c
@@ -23,10 +23,9 @@
#include <errno.h>
#include <gpgme.h>
+#include "constants.h"
#include "r-gpgme.h"
-#define BUF_SIZE 128
-
#ifdef DEBUG
#define ret_if_err(ret, err) \
do { \
@@ -79,7 +78,7 @@ static int init_ctx(gpgme_ctx_t ctx, gpgme_protocol_t protocol)
static int loop_read(const char *path, gpgme_data_t dh)
{
- char buf[BUF_SIZE];
+ char buf[maxlen_pass];
int ret;
FILE *f = fopen(path, "w");
@@ -91,7 +90,7 @@ static int loop_read(const char *path, gpgme_data_t dh)
fclose(f);
ret_if_err(1, gpgme_err_code_from_errno(errno));
}
- while((ret = gpgme_data_read(dh, buf, BUF_SIZE)) > 0)
+ while((ret = gpgme_data_read(dh, buf, maxlen_pass)) > 0)
fwrite(buf, ret, 1, f);
if(ret < 0) {
fclose(f);
@@ -165,8 +164,8 @@ char *decrypt_data(const char *path)
if(ret)
ret_if_err(NULL, gpgme_err_code_from_errno(errno));
- char *data = malloc(sizeof(char) * (BUF_SIZE + 1));
- gpgme_data_read(plain, data, BUF_SIZE);
+ char *data = malloc(sizeof(char) * (maxlen_pass + 1));
+ gpgme_data_read(plain, data, maxlen_pass);
gpgme_data_release(plain);
gpgme_data_release(cipher);