aboutsummaryrefslogtreecommitdiff
path: root/pass_util.c
diff options
context:
space:
mode:
authorsinanmohd <sinan@sinanmohd.com>2023-12-30 19:00:32 +0530
committersinanmohd <sinan@sinanmohd.com>2023-12-30 19:00:46 +0530
commit7960f6b6d80d64001282b7b0b43c0195645cc35c (patch)
tree99db4218323383fbea99faccfed2b67fcd9735f3 /pass_util.c
parent1a56879bb29e307bd6b00e250e67597235fa0adf (diff)
pass: support unlimited password length
Diffstat (limited to 'pass_util.c')
-rw-r--r--pass_util.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/pass_util.c b/pass_util.c
index 7147681..d9d6fc3 100644
--- a/pass_util.c
+++ b/pass_util.c
@@ -17,7 +17,6 @@
#define FPR_MAX 256
static char pass_dir[PATH_MAX] = {0};
-static char pass_out[PASS_MAX] = {0};
int set_pass_dir(void);
@@ -82,21 +81,21 @@ int pass_init(const char *fpr)
return 0;
}
-const char *pass_cat(const char *path)
+int pass_cat(FILE *out, const char *path)
{
int r;
char pass_path[PATH_MAX];
r = set_pass_dir();
if (r)
- err_die(NULL, "PASSWORD_STORE_DIR not set");
+ err_die(1, "PASSWORD_STORE_DIR not set");
r = snprintf(pass_path, sizeof(pass_path), "%s/%s.gpg", pass_dir, path);
if (r >= (int) sizeof(pass_path))
- err_die(NULL, "path exceeded PATH_MAX");
+ err_die(1, "path exceeded PATH_MAX");
- r = gpg_decrypt(pass_path, pass_out, sizeof(pass_out));
- return r ? NULL : pass_out;
+ r = gpg_decrypt(out, pass_path);
+ return r;
}
ssize_t pass_getpass(char **lineptr, size_t *n, FILE *stream)