Coverage Report

Created: 2022-11-30 06:20

/src/openssl/crypto/comp/comp_lib.c
Line
Count
Source (jump to first uncovered line)
1
#include <stdio.h>
2
#include <stdlib.h>
3
#include <string.h>
4
#include <openssl/objects.h>
5
#include <openssl/comp.h>
6
7
COMP_CTX *COMP_CTX_new(COMP_METHOD *meth)
8
0
{
9
0
    COMP_CTX *ret;
10
11
0
    if ((ret = (COMP_CTX *)OPENSSL_malloc(sizeof(COMP_CTX))) == NULL) {
12
        /* ZZZZZZZZZZZZZZZZ */
13
0
        return (NULL);
14
0
    }
15
0
    memset(ret, 0, sizeof(COMP_CTX));
16
0
    ret->meth = meth;
17
0
    if ((ret->meth->init != NULL) && !ret->meth->init(ret)) {
18
0
        OPENSSL_free(ret);
19
0
        ret = NULL;
20
0
    }
21
0
    return (ret);
22
0
}
23
24
void COMP_CTX_free(COMP_CTX *ctx)
25
0
{
26
0
    if (ctx == NULL)
27
0
        return;
28
29
0
    if (ctx->meth->finish != NULL)
30
0
        ctx->meth->finish(ctx);
31
32
0
    OPENSSL_free(ctx);
33
0
}
34
35
int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen,
36
                        unsigned char *in, int ilen)
37
0
{
38
0
    int ret;
39
0
    if (ctx->meth->compress == NULL) {
40
        /* ZZZZZZZZZZZZZZZZZ */
41
0
        return (-1);
42
0
    }
43
0
    ret = ctx->meth->compress(ctx, out, olen, in, ilen);
44
0
    if (ret > 0) {
45
0
        ctx->compress_in += ilen;
46
0
        ctx->compress_out += ret;
47
0
    }
48
0
    return (ret);
49
0
}
50
51
int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen,
52
                      unsigned char *in, int ilen)
53
0
{
54
0
    int ret;
55
56
0
    if (ctx->meth->expand == NULL) {
57
        /* ZZZZZZZZZZZZZZZZZ */
58
0
        return (-1);
59
0
    }
60
0
    ret = ctx->meth->expand(ctx, out, olen, in, ilen);
61
0
    if (ret > 0) {
62
0
        ctx->expand_in += ilen;
63
0
        ctx->expand_out += ret;
64
0
    }
65
0
    return (ret);
66
0
}