diff --git a/bipmkpw.1 b/bipmkpw.1 index 3dfaee1..de85379 100644 --- a/bipmkpw.1 +++ b/bipmkpw.1 @@ -13,6 +13,8 @@ bipmkpw \- Password hasher for BIP bipmkpw converts a password into the double-hash used by bip. Copy the generated output from bipmkpw into bip config file. +Password cannot contain spaces. + .SH SEE ALSO bip.conf diff --git a/src/bipmkpw.c b/src/bipmkpw.c index 20fb0b4..cc2d5ff 100644 --- a/src/bipmkpw.c +++ b/src/bipmkpw.c @@ -51,11 +51,14 @@ void readpass(char *buffer, int buflen) write(ttyfd, "Password: ", 10); int idx = 0; + int valid = 1; while (idx < buflen) { read(ttyfd, buffer+idx, 1); if (buffer[idx] == '\n') { buffer[idx] = 0; break; + } else if (buffer[idx] == ' ') { + valid = 0; } idx++; } @@ -64,6 +67,11 @@ void readpass(char *buffer, int buflen) tcsetattr(ttyfd, TCSANOW, &ttback); close(ttyfd); + + if (!valid) { + fprintf(stderr, "Password cannot contain spaces.\n"); + exit(1); + } } int main(void)