Fix tomb-kdb-pbkdf2 helper for multiplatform build

Avoid EOF being missed when reading in the password. Replace undefined
char-to-int comparison with a int-to-int one. Fix #360
This commit is contained in:
Jaromil 2019-08-22 11:42:56 +02:00
parent 6f2ce59d29
commit 187a627022
2 changed files with 5 additions and 5 deletions

View File

@ -28,8 +28,8 @@ The Grugq, Reiven, GDrooid, Alphazo, Brian May, fsLeg, JoelMon,
Narrat, Jerry Polfer, Jim Turner, Maxime Arthaud, RobertMX,
mhogomchungu Mandeep Bhutani, Emil Lundberg, Joel Montes de Oca, Armin
Mesbah, Arusekk, Stephan Schindel, Asbjørn Apeland, Victor Calvert,
bjonnh, SargoDevel, AitorATuin, Alexis Danizan and... the Linux
Action Show!
bjonnh, SargoDevel, AitorATuin, Alexis Danizan, Sven Geuer and...
the Linux Action Show!
Tomb includes an implementation of the "Password-Based Key Derivation
Function v2" based on GCrypt and written by Anthony Thyssen, with

View File

@ -140,18 +140,18 @@ int main(int argc, char *argv[])
* passwords containing just a bunch of spaces are valid
*/
pass = calloc(buff_len, sizeof(char));
char c = getchar();
int c = getchar();
while (c != EOF) {
if (pw_len == buff_len) {
buff_len *= 2;
pass = realloc(pass, buff_len);
if (!pass) {
fprintf(stderr, "Error allocating memory");
fprintf(stderr, "Error allocating memory\n");
cleanup(result, result_len, pass, salt, salt_len);
exit(3);
}
}
pass[pw_len] = c;
pass[pw_len] = (char)c;
pw_len++;
c = getchar();
}