Initialize return values to an error
Initializing the return values to an error is best practice and makes
the library more robust against programmer errors.
diff --git a/library/ssl_cookie.c b/library/ssl_cookie.c
index 56e9bdd..1635832 100644
--- a/library/ssl_cookie.c
+++ b/library/ssl_cookie.c
@@ -38,6 +38,7 @@
#define mbedtls_free free
#endif
+#include "mbedtls/error.h"
#include "mbedtls/ssl_cookie.h"
#include "mbedtls/ssl_internal.h"
#include "mbedtls/platform_util.h"
@@ -104,7 +105,7 @@
int (*f_rng)(void *, unsigned char *, size_t),
void *p_rng )
{
- int ret;
+ int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
unsigned char key[COOKIE_MD_OUTLEN];
if( ( ret = f_rng( p_rng, key, sizeof( key ) ) ) != 0 )
@@ -157,7 +158,7 @@
unsigned char **p, unsigned char *end,
const unsigned char *cli_id, size_t cli_id_len )
{
- int ret;
+ int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
mbedtls_ssl_cookie_ctx *ctx = (mbedtls_ssl_cookie_ctx *) p_ctx;
unsigned long t;