summaryrefslogtreecommitdiffhomepage
path: root/libtomcrypt/demos
diff options
context:
space:
mode:
Diffstat (limited to 'libtomcrypt/demos')
-rw-r--r--libtomcrypt/demos/constants.c3
-rw-r--r--libtomcrypt/demos/sizes.c6
-rw-r--r--libtomcrypt/demos/timing.c2
-rw-r--r--libtomcrypt/demos/tv_gen.c2
4 files changed, 8 insertions, 5 deletions
diff --git a/libtomcrypt/demos/constants.c b/libtomcrypt/demos/constants.c
index f747eb5..50485ad 100644
--- a/libtomcrypt/demos/constants.c
+++ b/libtomcrypt/demos/constants.c
@@ -65,9 +65,10 @@ int main(int argc, char **argv)
/* get and print the length of the names (and values) list */
if (crypt_list_all_constants(NULL, &names_list_len) != 0) exit(EXIT_FAILURE);
/* get and print the names (and values) list */
- names_list = malloc(names_list_len);
+ if ((names_list = malloc(names_list_len)) == NULL) exit(EXIT_FAILURE);
if (crypt_list_all_constants(names_list, &names_list_len) != 0) exit(EXIT_FAILURE);
printf("%s\n", names_list);
+ free(names_list);
}
} else if (argc == 3) {
if (strcmp(argv[1], "-s") == 0) {
diff --git a/libtomcrypt/demos/sizes.c b/libtomcrypt/demos/sizes.c
index 54d1979..c939b71 100644
--- a/libtomcrypt/demos/sizes.c
+++ b/libtomcrypt/demos/sizes.c
@@ -42,9 +42,10 @@ int main(int argc, char **argv)
printf(" need to allocate %u bytes \n\n", sizes_list_len);
/* get and print the names (and sizes) list */
- sizes_list = malloc(sizes_list_len);
+ if ((sizes_list = malloc(sizes_list_len)) == NULL) exit(EXIT_FAILURE);
if (crypt_list_all_sizes(sizes_list, &sizes_list_len) != 0) exit(EXIT_FAILURE);
printf(" supported sizes:\n\n%s\n\n", sizes_list);
+ free(sizes_list);
} else if (argc == 2) {
if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0) {
char* base = strdup(basename(argv[0]));
@@ -60,9 +61,10 @@ int main(int argc, char **argv)
/* get and print the length of the names (and sizes) list */
if (crypt_list_all_sizes(NULL, &sizes_list_len) != 0) exit(EXIT_FAILURE);
/* get and print the names (and sizes) list */
- sizes_list = malloc(sizes_list_len);
+ if ((sizes_list = malloc(sizes_list_len)) == NULL) exit(EXIT_FAILURE);
if (crypt_list_all_sizes(sizes_list, &sizes_list_len) != 0) exit(EXIT_FAILURE);
printf("%s\n", sizes_list);
+ free(sizes_list);
}
} else if (argc == 3) {
if (strcmp(argv[1], "-s") == 0) {
diff --git a/libtomcrypt/demos/timing.c b/libtomcrypt/demos/timing.c
index 14a59df..8f69ed6 100644
--- a/libtomcrypt/demos/timing.c
+++ b/libtomcrypt/demos/timing.c
@@ -466,7 +466,7 @@ static void time_cipher_lrw(void)
tally_results(1);
}
#else
-static void time_cipher_lrw(void) { fprintf(stderr, "NO LRW\n"); return 0; }
+static void time_cipher_lrw(void) { fprintf(stderr, "NO LRW\n"); }
#endif
diff --git a/libtomcrypt/demos/tv_gen.c b/libtomcrypt/demos/tv_gen.c
index 127c114..f49c7fd 100644
--- a/libtomcrypt/demos/tv_gen.c
+++ b/libtomcrypt/demos/tv_gen.c
@@ -78,7 +78,7 @@ void cipher_gen(void)
printf("keysize error: %s\n", error_to_string(err));
exit(EXIT_FAILURE);
}
- if (kl == lastkl) break;
+ if (kl == lastkl) continue;
lastkl = kl;
fprintf(out, "Key Size: %d bytes\n", kl);