aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Tay <nick@windblume.net>2022-01-13 23:02:10 +1100
committerNicholas Tay <nick@windblume.net>2022-01-13 23:02:10 +1100
commitafd063a3ce9936f5eb1f5fd00fff6423f782994e (patch)
tree380a6486845e7ce2b76b25d6e5c637ccf94144e0
parent9e04a51d0bc7dbe2ce642b115ca25fafe757e511 (diff)
downloadpassgen-afd063a3ce9936f5eb1f5fd00fff6423f782994e.tar.gz
passgen-afd063a3ce9936f5eb1f5fd00fff6423f782994e.tar.bz2
passgen-afd063a3ce9936f5eb1f5fd00fff6423f782994e.zip
Fix generation for number params (forgot grammar_size)
Diffstat (limited to '')
-rw-r--r--passgen.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/passgen.c b/passgen.c
index ee78a89..0b5f754 100644
--- a/passgen.c
+++ b/passgen.c
@@ -86,20 +86,20 @@ unsigned int get_rng(void)
return r;
}
-char *build_grammar(int triplets, int specials, int numbers)
+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;
}
- int grammar_size = triplets * 3 + specials + numbers;
- char *build = malloc(grammar_size + 1);
+ *grammar_size = triplets * 3 + specials + numbers;
+ char *build = malloc(*grammar_size + 1);
if (build == NULL) {
perror("malloc");
return NULL;
}
- build[grammar_size] = 0;
+ build[*grammar_size] = 0;
memcpy(build, "Cvc", 3);
for (int i = 1; i < triplets; ++i)
@@ -127,7 +127,7 @@ int main(int argc, char *argv[])
* Take arguments as triplets, specials, numbers
* atoi might be scuffed but so be it (it just goes = 0 if invalid input)
*/
- grammar = build_grammar(atoi(argv[1]), atoi(argv[2]), atoi(argv[3]));
+ grammar = build_grammar(atoi(argv[1]), atoi(argv[2]), atoi(argv[3]), &grammar_size);
if (grammar == NULL) {
err = true;
goto cleanup;