From 4a00c265fe425c8a7fe2e6149cad96861212cec7 Mon Sep 17 00:00:00 2001 From: Nicholas Tay Date: Wed, 1 Dec 2021 16:04:37 +1100 Subject: Fix VLA for password chars I wasn't very clued in on how this works, and I thought it'd initialise properly, but clearly not. Need to include space for the null terminator and explicitly set it. --- passgen.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/passgen.c b/passgen.c index bdcd04a..a4ff892 100644 --- a/passgen.c +++ b/passgen.c @@ -48,7 +48,8 @@ int main(int argc, char *argv[]) //printf("Custom: %s\n", grammar); } - char password[grammar_size]; + char password[grammar_size+1]; + password[grammar_size] = 0; // seed RNG; this isn't very good, but it's enough (for now) srand(time(NULL) + getpid() % 420 - 69); -- cgit