commit - 9999d2cefab8cc6545e0bae2fc3343361f89fbac
commit + 11cbec53c60d0c9b32431eee4a0932072871acd0
blob - bfd563736b80a559ce68a081a491d846871b1f57
blob + 4f5de4e909738bf2c8483a2601b3ed44654f4f2c
--- gpass.c
+++ gpass.c
#include <sodium.h>
#define MAXWORDS 128
+#define RANDLINE (int)randombytes_uniform(nlines)+1
#ifndef PREFIX
- #define PREFIX "/usr/local"
+# define PREFIX "/usr/local"
#endif
char *dictname = NULL;
int plen = 70, nlines = 0, npass = 1;
FILE *dictfp;
-#define RANDLINE (int)randombytes_uniform(nlines)+1
-
int
usage(void)
{
rewind(dictfp);
char c;
for (int left = plen, cur = 1, sought = RANDLINE; left;
- cur += (c == '\n' || c == EOF)) {
+ cur += (c == '\n')) {
c = getc(dictfp);
if (cur == sought) {
for (; c != '\n' && c != EOF; c = getc(dictfp))
case 'e':
plen = strtonum(optarg, 1, INT_MAX, NULL);
if (!plen)
- err(1, "bad entropy");
+ errx(1, "bad entropy (must be 1-%d bits)",
+ INT_MAX);
break;
case 'n':
npass = strtonum(optarg, 1, INT_MAX, NULL);
if (!npass)
- err(1, "bad number of passphrases");
+ errx(1,
+ "bad number of passphrases (must be 1-%d)",
+ INT_MAX);
break;
default:
usage();