Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/comp/comp_lib.c |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /* | - | ||||||||||||
2 | * Copyright 1998-2018 The OpenSSL Project Authors. All Rights Reserved. | - | ||||||||||||
3 | * | - | ||||||||||||
4 | * Licensed under the OpenSSL license (the "License"). You may not use | - | ||||||||||||
5 | * this file except in compliance with the License. You can obtain a copy | - | ||||||||||||
6 | * in the file LICENSE in the source distribution or at | - | ||||||||||||
7 | * https://www.openssl.org/source/license.html | - | ||||||||||||
8 | */ | - | ||||||||||||
9 | - | |||||||||||||
10 | #include <stdio.h> | - | ||||||||||||
11 | #include <stdlib.h> | - | ||||||||||||
12 | #include <string.h> | - | ||||||||||||
13 | #include <openssl/objects.h> | - | ||||||||||||
14 | #include <openssl/comp.h> | - | ||||||||||||
15 | #include <openssl/err.h> | - | ||||||||||||
16 | #include "comp_lcl.h" | - | ||||||||||||
17 | - | |||||||||||||
18 | COMP_CTX *COMP_CTX_new(COMP_METHOD *meth) | - | ||||||||||||
19 | { | - | ||||||||||||
20 | COMP_CTX *ret; | - | ||||||||||||
21 | - | |||||||||||||
22 | if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {
| 0 | ||||||||||||
23 | COMPerr(COMP_F_COMP_CTX_NEW, ERR_R_MALLOC_FAILURE); | - | ||||||||||||
24 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||
25 | } | - | ||||||||||||
26 | ret->meth = meth; | - | ||||||||||||
27 | if ((ret->meth->init != NULL) && !ret->meth->init(ret)) {
| 0 | ||||||||||||
28 | OPENSSL_free(ret); | - | ||||||||||||
29 | ret = NULL; | - | ||||||||||||
30 | } never executed: end of block | 0 | ||||||||||||
31 | return ret; never executed: return ret; | 0 | ||||||||||||
32 | } | - | ||||||||||||
33 | - | |||||||||||||
34 | const COMP_METHOD *COMP_CTX_get_method(const COMP_CTX *ctx) | - | ||||||||||||
35 | { | - | ||||||||||||
36 | return ctx->meth; never executed: return ctx->meth; | 0 | ||||||||||||
37 | } | - | ||||||||||||
38 | - | |||||||||||||
39 | int COMP_get_type(const COMP_METHOD *meth) | - | ||||||||||||
40 | { | - | ||||||||||||
41 | return meth->type; executed 1958 times by 1 test: return meth->type; Executed by:
| 1958 | ||||||||||||
42 | } | - | ||||||||||||
43 | - | |||||||||||||
44 | const char *COMP_get_name(const COMP_METHOD *meth) | - | ||||||||||||
45 | { | - | ||||||||||||
46 | return meth->name; never executed: return meth->name; | 0 | ||||||||||||
47 | } | - | ||||||||||||
48 | - | |||||||||||||
49 | void COMP_CTX_free(COMP_CTX *ctx) | - | ||||||||||||
50 | { | - | ||||||||||||
51 | if (ctx == NULL)
| 0-70251 | ||||||||||||
52 | return; executed 70251 times by 1 test: return; Executed by:
| 70251 | ||||||||||||
53 | if (ctx->meth->finish != NULL)
| 0 | ||||||||||||
54 | ctx->meth->finish(ctx); never executed: ctx->meth->finish(ctx); | 0 | ||||||||||||
55 | - | |||||||||||||
56 | OPENSSL_free(ctx); | - | ||||||||||||
57 | } never executed: end of block | 0 | ||||||||||||
58 | - | |||||||||||||
59 | int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen, | - | ||||||||||||
60 | unsigned char *in, int ilen) | - | ||||||||||||
61 | { | - | ||||||||||||
62 | int ret; | - | ||||||||||||
63 | if (ctx->meth->compress == NULL) {
| 0 | ||||||||||||
64 | return -1; never executed: return -1; | 0 | ||||||||||||
65 | } | - | ||||||||||||
66 | ret = ctx->meth->compress(ctx, out, olen, in, ilen); | - | ||||||||||||
67 | if (ret > 0) {
| 0 | ||||||||||||
68 | ctx->compress_in += ilen; | - | ||||||||||||
69 | ctx->compress_out += ret; | - | ||||||||||||
70 | } never executed: end of block | 0 | ||||||||||||
71 | return ret; never executed: return ret; | 0 | ||||||||||||
72 | } | - | ||||||||||||
73 | - | |||||||||||||
74 | int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen, | - | ||||||||||||
75 | unsigned char *in, int ilen) | - | ||||||||||||
76 | { | - | ||||||||||||
77 | int ret; | - | ||||||||||||
78 | - | |||||||||||||
79 | if (ctx->meth->expand == NULL) {
| 0 | ||||||||||||
80 | return -1; never executed: return -1; | 0 | ||||||||||||
81 | } | - | ||||||||||||
82 | ret = ctx->meth->expand(ctx, out, olen, in, ilen); | - | ||||||||||||
83 | if (ret > 0) {
| 0 | ||||||||||||
84 | ctx->expand_in += ilen; | - | ||||||||||||
85 | ctx->expand_out += ret; | - | ||||||||||||
86 | } never executed: end of block | 0 | ||||||||||||
87 | return ret; never executed: return ret; | 0 | ||||||||||||
88 | } | - | ||||||||||||
89 | - | |||||||||||||
90 | int COMP_CTX_get_type(const COMP_CTX* comp) | - | ||||||||||||
91 | { | - | ||||||||||||
92 | return comp->meth ? comp->meth->type : NID_undef; never executed: return comp->meth ? comp->meth->type : 0;
| 0 | ||||||||||||
93 | } | - | ||||||||||||
Source code | Switch to Preprocessed file |