commit a01558fb8f446f6eeaa725cbbcec132c0232da7b
parent db4303793040120df2b53f6906ffb28f399f31c2
Author: Naveen Narayanan zerous <zerous@nocebo.space>
Date: Fri, 29 Dec 2017 14:16:36 +0300
Remove inessential check. define MAX_BUFSIZ
Diffstat:
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/pass.c b/pass.c
@@ -15,6 +15,7 @@
#include "pass.h"
#include "readpassphrase.h"
+#define MAX_BUFSIZ 512
static char file[PATH_MAX];
void
@@ -102,7 +103,7 @@ decrypt(char *buf)
void
printpass(char *item)
{
- char buf[512];
+ char buf[MAX_BUFSIZ];
const char* home;
int fin;
@@ -150,9 +151,7 @@ mkdirp(const char *tp)
snprintf(file, sizeof(file), "%s/%s", t, tp);
printf("mkdir %s\n", file);
if ((r = mkdir(file, mode)) == -1) {
- if (errno == EEXIST)
- ;
- else
+ if (errno != EEXIST)
fatal("mkdir");
}
tp = i + 1;
@@ -168,14 +167,14 @@ encrypt()
gpgme_key_t key;
gpgme_key_t keys[2];
gpgme_protocol_t proto;
- char uid[128], t[PATH_MAX];
+ char uid[MAX_BUFSIZ], t[PATH_MAX];
FILE *fin, *fout;
proto = GPGME_PROTOCOL_OpenPGP;
key = NULL;
initgpgme();
- getuserid(uid, 128);
+ getuserid(uid, MAX_BUFSIZ);
gpgerr = gpgme_new(&ctx);
if (gpgme_err_code(gpgerr) != GPG_ERR_NO_ERROR)
fatalgpg(gpgerr, "gpme_new");
@@ -220,7 +219,7 @@ insert(char *item)
char *filename, t[PATH_MAX];
const char *home;
FILE *fp;
- char pass[128];
+ char pass[MAX_BUFSIZ];
int c, fd;
c = 'y';
@@ -251,9 +250,9 @@ insert(char *item)
if (!(fp = fopen(file, "w+b")))
fatal("fopen: %s", file);
if (isatty(fd)) {
- readpassphrase("Enter password: ", pass, 128, RPP_ECHO_OFF);
+ readpassphrase("Enter password: ", pass, MAX_BUFSIZ, RPP_ECHO_OFF);
memcpy(t, pass, strlen(pass) + 1);
- readpassphrase("Retype password: ", pass, 128, RPP_ECHO_OFF);
+ readpassphrase("Retype password: ", pass, MAX_BUFSIZ, RPP_ECHO_OFF);
if (!strcmp(pass, t))
{
int i = 0;