Make sure output length argument is not NULL 21/74821/1
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Wed, 15 Jun 2016 15:32:31 +0000 (17:32 +0200)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Wed, 15 Jun 2016 15:32:31 +0000 (17:32 +0200)
Change-Id: I2ed584063314213efba934b282f603ce49f69899

src/crypto.c
src/digest.c
src/encrypt.c
src/sign.c

index 6acdc2a..40f6a99 100644 (file)
@@ -291,7 +291,7 @@ API int yaca_context_destroy(yaca_context_h ctx)
 API int yaca_context_get_output_length(const yaca_context_h ctx,
                                        size_t input_len, size_t *output_len)
 {
-       if (ctx == YACA_CONTEXT_NULL)
+       if (ctx == YACA_CONTEXT_NULL || output_len == NULL)
                return YACA_ERROR_INVALID_PARAMETER;
 
        return ctx->get_output_length(ctx, input_len, output_len);
index 235a0a2..64b88f4 100644 (file)
@@ -54,6 +54,8 @@ static int get_digest_output_length(const yaca_context_h ctx,
                                     UNUSED size_t input_len,
                                     size_t *output_len)
 {
+       assert(output_len != NULL);
+
        struct yaca_digest_ctx_s *c = get_digest_ctx(ctx);
 
        if (c == NULL)
index 7a01f33..5942e2e 100644 (file)
@@ -59,6 +59,8 @@ void destroy_encrypt_context(const yaca_context_h ctx)
 
 int get_encrypt_output_length(const yaca_context_h ctx, size_t input_len, size_t *output_len)
 {
+       assert(output_len != NULL);
+
        struct yaca_encrypt_context_s *nc = get_encrypt_context(ctx);
        int block_size;
 
index 7be2005..98543e0 100644 (file)
@@ -67,6 +67,8 @@ static int get_sign_output_length(const yaca_context_h ctx,
                                   UNUSED size_t input_len,
                                   size_t *output_len)
 {
+       assert(output_len != NULL);
+
        struct yaca_sign_ctx_s *c = get_sign_ctx(ctx);
 
        if (c == NULL)