From 4b305c5721f68e39320ca2e15b03a411da2305f1 Mon Sep 17 00:00:00 2001 From: Matt Johnston Date: Wed, 10 Jun 2020 23:16:13 +0800 Subject: Merge libtomcrypt v1.18.2 --- libtomcrypt/src/misc/crypt/crypt_sizes.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'libtomcrypt/src/misc/crypt/crypt_sizes.c') diff --git a/libtomcrypt/src/misc/crypt/crypt_sizes.c b/libtomcrypt/src/misc/crypt/crypt_sizes.c index 79b3bd4..dd857ea 100644 --- a/libtomcrypt/src/misc/crypt/crypt_sizes.c +++ b/libtomcrypt/src/misc/crypt/crypt_sizes.c @@ -307,19 +307,16 @@ int crypt_get_size(const char* namein, unsigned int *sizeout) { int crypt_list_all_sizes(char *names_list, unsigned int *names_list_size) { int i; unsigned int total_len = 0; - char number[32], *ptr; + char *ptr; int number_len; int count = sizeof(_crypt_sizes) / sizeof(_crypt_sizes[0]); /* calculate amount of memory required for the list */ for (i=0; i= sizeof(number))) + number_len = snprintf(NULL, 0, "%s,%u\n", _crypt_sizes[i].name, _crypt_sizes[i].size); + if (number_len < 0) return -1; - total_len += (unsigned int)strlen(number) + 1; + total_len += number_len; /* this last +1 is for newlines (and ending NULL) */ } @@ -332,16 +329,11 @@ int crypt_list_all_sizes(char *names_list, unsigned int *names_list_size) { /* build the names list */ ptr = names_list; for (i=0; i total_len) return -1; + total_len -= number_len; ptr += number_len; - strcpy(ptr, "\n"); - ptr += 1; } /* to remove the trailing new-line */ ptr -= 1; -- cgit v1.2.3