diff --git a/MasterPassword/C/mpw.c b/MasterPassword/C/mpw.c index f6fd7ff9..5059aabf 100644 --- a/MasterPassword/C/mpw.c +++ b/MasterPassword/C/mpw.c @@ -199,11 +199,14 @@ int main(int argc, char *const argv[]) { char *line = NULL; size_t linecap = 0; ssize_t linelen; - while ((linelen = getline(&line, &linecap, mpwConfig)) > 0) - if (strcmp(strsep(&line, ":"), userName) == 0) { - masterPassword = strsep(&line, "\n"); + while ((linelen = getline(&line, &linecap, mpwConfig)) > 0) { + char *lineData = line; + if (strcmp(strsep(&lineData, ":"), userName) == 0) { + masterPassword = strsep(&lineData, "\n"); break; } + } + free(line); } while (!masterPassword) masterPassword = getpass( "Your master password: " ); diff --git a/MasterPassword/C/types.c b/MasterPassword/C/types.c index 3997782f..0dccb204 100644 --- a/MasterPassword/C/types.c +++ b/MasterPassword/C/types.c @@ -15,8 +15,10 @@ #include +#ifdef COLOR #include #include +#endif #include "types.h" @@ -222,15 +224,10 @@ const char *Identicon(const char *userName, const char *masterPassword) { uint8_t identiconSeed[32]; HMAC_SHA256_Buf(masterPassword, strlen(masterPassword), userName, strlen(userName), identiconSeed); - bool useColor = 0; -#ifdef COLOR - if (isatty(STDERR_FILENO)) - useColor = 1; -#endif - uint8_t colorIdentifier = identiconSeed[4] % 7 + 1; char *colorString, *resetString; - if (useColor) { +#ifdef COLOR + if (isatty( STDERR_FILENO )) { initputvar(); tputs(tparm(tgetstr("AF", NULL), colorIdentifier), 1, putvar); colorString = calloc(strlen(putvarc) + 1, sizeof(char)); @@ -238,7 +235,9 @@ const char *Identicon(const char *userName, const char *masterPassword) { tputs(tgetstr("me", NULL), 1, putvar); resetString = calloc(strlen(putvarc) + 1, sizeof(char)); strcpy(resetString, putvarc); - } else { + } else +#endif + { colorString = calloc(1, sizeof(char)); resetString = calloc(1, sizeof(char)); }