1
0
forked from bip/bip

ensure null terminated str

This commit is contained in:
Arnaud Cornet 2008-12-29 14:04:51 +01:00
parent 5a5f1b8bfb
commit a4b101cea8

View File

@ -37,14 +37,14 @@ void readpass(char *buffer, int buflen)
struct termios tt, ttback;
memset(&ttback, 0, sizeof(ttback));
if (tcgetattr(ttyfd, &ttback) < 0) {
printf("tcgetattr failed: %s\n", strerror(errno));
fprintf(stderr, "tcgetattr failed: %s\n", strerror(errno));
exit(1);
}
memcpy(&tt, &ttback, sizeof(ttback));
tt.c_lflag &= ~(ICANON|ECHO);
if (tcsetattr(ttyfd, TCSANOW, &tt) < 0) {
printf("tcsetattr failed: %s\n", strerror(errno));
fprintf(stderr, "tcsetattr failed: %s\n", strerror(errno));
exit(1);
}
@ -74,6 +74,7 @@ int main(void)
unsigned int seed;
readpass(str, 256);
str[255] = 0;
// the time used to type the pass is entropy
srand(time(NULL));