diff options
author | Nicholas Tay <nick@windblume.net> | 2022-01-13 23:21:42 +1100 |
---|---|---|
committer | Nicholas Tay <nick@windblume.net> | 2022-01-13 23:21:42 +1100 |
commit | a6de6290a560c304a4e938bbd1a584a1c710e15e (patch) | |
tree | 988146eaf63066ff2ba0281a35145d8f072e2e51 /passgen.c | |
parent | 1414a5667339637ca815dee52a527abb9bcfc528 (diff) | |
download | passgen-a6de6290a560c304a4e938bbd1a584a1c710e15e.tar.gz passgen-a6de6290a560c304a4e938bbd1a584a1c710e15e.tar.bz2 passgen-a6de6290a560c304a4e938bbd1a584a1c710e15e.zip |
Allow 0 triplets
Diffstat (limited to 'passgen.c')
-rw-r--r-- | passgen.c | 13 |
1 files changed, 5 insertions, 8 deletions
@@ -91,10 +91,6 @@ char password_buf[STATIC_BUFFER_SIZE + 1]; char *build_grammar(int triplets, int specials, int numbers, int *grammar_size) { - if (triplets < 1) { - fprintf(stderr, "ERROR: Cannot have less than one triplet."); - return NULL; - } *grammar_size = triplets * 3 + specials + numbers; char *build = grammar_buf; @@ -107,10 +103,11 @@ char *build_grammar(int triplets, int specials, int numbers, int *grammar_size) } build[*grammar_size] = 0; - memcpy(build, "Cvc", 3); - for (int i = 1; i < triplets; ++i) - memcpy(build + (i * 3), "cvc", 3); - + if (triplets > 0) { + memcpy(build, "Cvc", 3); + for (int i = 1; i < triplets; ++i) + memcpy(build + (i * 3), "cvc", 3); + } memset(build + (triplets * 3), '!', specials); memset(build + (triplets * 3) + specials, '#', numbers); return build; |