diff options
| author | Steve McIntyre <93sam@debian.org> | 2021-02-21 13:46:16 +0000 |
|---|---|---|
| committer | Steve McIntyre <93sam@debian.org> | 2021-02-21 13:46:16 +0000 |
| commit | 2a55644555e3c9bb1d948ab817b047123c1dcfd9 (patch) | |
| tree | f3c68875b270405a4cf93cec1b9aa5fb567e0c48 /Cryptlib/OpenSSL/crypto/comp/c_rle.c | |
| parent | 379f0954e0632f29f5154a0157a046ef20053121 (diff) | |
| parent | 888f5b544b7cce3cdae8074aa617b1d4add271a1 (diff) | |
| download | efi-boot-shim-2a55644555e3c9bb1d948ab817b047123c1dcfd9.tar.gz efi-boot-shim-2a55644555e3c9bb1d948ab817b047123c1dcfd9.zip | |
Update upstream source from tag 'upstream/15+1613861442.888f5b5'
Update to upstream version '15+1613861442.888f5b5'
with Debian dir 15b0853a73144b1f8571ce2bebc2eea68af4a8e3
Diffstat (limited to 'Cryptlib/OpenSSL/crypto/comp/c_rle.c')
| -rw-r--r-- | Cryptlib/OpenSSL/crypto/comp/c_rle.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/Cryptlib/OpenSSL/crypto/comp/c_rle.c b/Cryptlib/OpenSSL/crypto/comp/c_rle.c new file mode 100644 index 00000000..e9aabbd1 --- /dev/null +++ b/Cryptlib/OpenSSL/crypto/comp/c_rle.c @@ -0,0 +1,62 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <openssl/objects.h> +#include <openssl/comp.h> + +static int rle_compress_block(COMP_CTX *ctx, unsigned char *out, + unsigned int olen, unsigned char *in, + unsigned int ilen); +static int rle_expand_block(COMP_CTX *ctx, unsigned char *out, + unsigned int olen, unsigned char *in, + unsigned int ilen); + +static COMP_METHOD rle_method = { + NID_rle_compression, + LN_rle_compression, + NULL, + NULL, + rle_compress_block, + rle_expand_block, + NULL, + NULL, +}; + +COMP_METHOD *COMP_rle(void) +{ + return (&rle_method); +} + +static int rle_compress_block(COMP_CTX *ctx, unsigned char *out, + unsigned int olen, unsigned char *in, + unsigned int ilen) +{ + /* int i; */ + + if (ilen == 0 || olen < (ilen - 1)) { + /* ZZZZZZZZZZZZZZZZZZZZZZ */ + return (-1); + } + + *(out++) = 0; + memcpy(out, in, ilen); + return (ilen + 1); +} + +static int rle_expand_block(COMP_CTX *ctx, unsigned char *out, + unsigned int olen, unsigned char *in, + unsigned int ilen) +{ + int i; + + if (olen < (ilen - 1)) { + /* ZZZZZZZZZZZZZZZZZZZZZZ */ + return (-1); + } + + i = *(in++); + if (i == 0) { + memcpy(out, in, ilen - 1); + } + return (ilen - 1); +} |
