]> git.pld-linux.org Git - packages/lessfs.git/blob - openssl.patch
- fix building with gcc 10+, rebuild with openssl 3.0.0, rel 2
[packages/lessfs.git] / openssl.patch
1 --- lessfs-1.7.0/lib_crypto.c.org       2011-09-30 20:13:08.000000000 +0200
2 +++ lessfs-1.7.0/lib_crypto.c   2018-09-26 13:16:08.995599693 +0200
3 @@ -78,7 +78,7 @@ unsigned char *safepassword()
4  DAT *lfsencrypt(unsigned char *unenc, unsigned long size)
5  {
6      unsigned char *safepasswd;
7 -    EVP_CIPHER_CTX ctx;
8 +    EVP_CIPHER_CTX *ctx;
9      DAT *encoded;
10      int olen, tlen;
11  
12 @@ -86,19 +86,24 @@ DAT *lfsencrypt(unsigned char *unenc, un
13  
14      pthread_mutex_lock(&crypto_mutex);
15      safepasswd = safepassword();
16 -    EVP_CIPHER_CTX_init(&ctx);
17 -    EVP_EncryptInit(&ctx, EVP_bf_cbc(), safepasswd, config->iv);
18 +    ctx = EVP_CIPHER_CTX_new();
19 +    if (ctx == NULL) {
20 +        die_cryptoerr("can't allocate memory for new ctx");
21 +    }
22 +    EVP_EncryptInit(ctx, EVP_bf_cbc(), safepasswd, config->iv);
23      encoded = s_malloc(sizeof(DAT));
24      encoded->data = s_malloc(8 + size); //Blowfish can grow 64 bits
25  
26 -    if (EVP_EncryptUpdate(&ctx, encoded->data, &olen, unenc, size) != 1) {
27 +    if (EVP_EncryptUpdate(ctx, encoded->data, &olen, unenc, size) != 1) {
28 +        EVP_CIPHER_CTX_free(ctx);
29          die_cryptoerr("error in encrypt update\n");
30      }
31  
32 -    if (EVP_EncryptFinal(&ctx, encoded->data + olen, &tlen) != 1) {
33 +    if (EVP_EncryptFinal(ctx, encoded->data + olen, &tlen) != 1) {
34 +        EVP_CIPHER_CTX_free(ctx);
35          die_cryptoerr("error in encrypt final\n");
36      }
37 -    EVP_CIPHER_CTX_cleanup(&ctx);
38 +    EVP_CIPHER_CTX_free(ctx);
39      encoded->size = olen + tlen;
40      if (encoded->size > 8 + size) {
41          die_cryptoerr
42 @@ -123,20 +128,24 @@ DAT *lfsdecrypt(DAT * data)
43      decrypted->data = s_malloc(data->size);
44      safepasswd = safepassword();
45  
46 -    EVP_CIPHER_CTX ctx;
47 -    EVP_CIPHER_CTX_init(&ctx);
48 -    EVP_DecryptInit(&ctx, EVP_bf_cbc(), safepasswd, config->iv);
49 +    EVP_CIPHER_CTX *ctx;
50 +    ctx = EVP_CIPHER_CTX_new();
51 +    if (ctx == NULL)
52 +        die_cryptoerr("can't allocate memory for new ctx");
53 +    EVP_DecryptInit(ctx, EVP_bf_cbc(), safepasswd, config->iv);
54  
55      if (EVP_DecryptUpdate
56 -        (&ctx, decrypted->data, &olen, data->data, data->size) != 1) {
57 +        (ctx, decrypted->data, &olen, data->data, data->size) != 1) {
58 +        EVP_CIPHER_CTX_free(ctx);
59          die_cryptoerr("Unexpected fatal error while decrypting.\n");
60      }
61  
62 -    if (EVP_DecryptFinal(&ctx, decrypted->data + olen, &tlen) != 1) {
63 +    if (EVP_DecryptFinal(ctx, decrypted->data + olen, &tlen) != 1) {
64 +        EVP_CIPHER_CTX_free(ctx);
65          die_cryptoerr("Unexpected fatal error in decrypt final.\n");
66      }
67      olen += tlen;
68 -    EVP_CIPHER_CTX_cleanup(&ctx);
69 +    EVP_CIPHER_CTX_free(ctx);
70      decrypted->size = olen;
71      s_free(safepasswd);
72      pthread_mutex_unlock(&crypto_mutex);
This page took 0.06197 seconds and 3 git commands to generate.