Password cannot contain spaces. Closes #265.

Thanks to Tim Hansen for reporting this bug.
This commit is contained in:
Pierre-Louis Bonicoli 2012-01-07 12:28:47 +01:00
parent df45c4c2d6
commit 2c390390ed
2 changed files with 10 additions and 0 deletions

View File

@ -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

View File

@ -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)