From 187a627022f759f4f3b8b4fc1c07ccc2dc68ba03 Mon Sep 17 00:00:00 2001 From: Jaromil Date: Thu, 22 Aug 2019 11:42:56 +0200 Subject: [PATCH] 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 --- AUTHORS.md | 4 ++-- extras/kdf-keys/pbkdf2.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/AUTHORS.md b/AUTHORS.md index d6d8685..aa6ce19 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -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 diff --git a/extras/kdf-keys/pbkdf2.c b/extras/kdf-keys/pbkdf2.c index afc8985..0a779a5 100644 --- a/extras/kdf-keys/pbkdf2.c +++ b/extras/kdf-keys/pbkdf2.c @@ -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(); }