-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathlessfs-1.7.0.patch
66 lines (59 loc) · 2.43 KB
/
lessfs-1.7.0.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
diff -Naur lessfs-1.7.0.orig/lib_crypto.c lessfs-1.7.0/lib_crypto.c
--- lessfs-1.7.0.orig/lib_crypto.c 2011-09-30 11:13:08.000000000 -0700
+++ lessfs-1.7.0/lib_crypto.c 2019-05-01 14:05:06.730749572 -0700
@@ -78,7 +78,7 @@
DAT *lfsencrypt(unsigned char *unenc, unsigned long size)
{
unsigned char *safepasswd;
- EVP_CIPHER_CTX ctx;
+ EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();
DAT *encoded;
int olen, tlen;
@@ -86,19 +86,20 @@
pthread_mutex_lock(&crypto_mutex);
safepasswd = safepassword();
- EVP_CIPHER_CTX_init(&ctx);
- EVP_EncryptInit(&ctx, EVP_bf_cbc(), safepasswd, config->iv);
+ EVP_CIPHER_CTX_init(ctx);
+ EVP_EncryptInit(ctx, EVP_bf_cbc(), safepasswd, config->iv);
encoded = s_malloc(sizeof(DAT));
encoded->data = s_malloc(8 + size); //Blowfish can grow 64 bits
- if (EVP_EncryptUpdate(&ctx, encoded->data, &olen, unenc, size) != 1) {
+ if (EVP_EncryptUpdate(ctx, encoded->data, &olen, unenc, size) != 1) {
die_cryptoerr("error in encrypt update\n");
}
- if (EVP_EncryptFinal(&ctx, encoded->data + olen, &tlen) != 1) {
+ if (EVP_EncryptFinal(ctx, encoded->data + olen, &tlen) != 1) {
die_cryptoerr("error in encrypt final\n");
}
- EVP_CIPHER_CTX_cleanup(&ctx);
+ EVP_CIPHER_CTX_cleanup(ctx);
+ EVP_CIPHER_CTX_free(ctx);
encoded->size = olen + tlen;
if (encoded->size > 8 + size) {
die_cryptoerr
@@ -123,20 +124,21 @@
decrypted->data = s_malloc(data->size);
safepasswd = safepassword();
- EVP_CIPHER_CTX ctx;
- EVP_CIPHER_CTX_init(&ctx);
- EVP_DecryptInit(&ctx, EVP_bf_cbc(), safepasswd, config->iv);
+ EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();
+ EVP_CIPHER_CTX_init(ctx);
+ EVP_DecryptInit(ctx, EVP_bf_cbc(), safepasswd, config->iv);
if (EVP_DecryptUpdate
- (&ctx, decrypted->data, &olen, data->data, data->size) != 1) {
+ (ctx, decrypted->data, &olen, data->data, data->size) != 1) {
die_cryptoerr("Unexpected fatal error while decrypting.\n");
}
- if (EVP_DecryptFinal(&ctx, decrypted->data + olen, &tlen) != 1) {
+ if (EVP_DecryptFinal(ctx, decrypted->data + olen, &tlen) != 1) {
die_cryptoerr("Unexpected fatal error in decrypt final.\n");
}
olen += tlen;
- EVP_CIPHER_CTX_cleanup(&ctx);
+ EVP_CIPHER_CTX_cleanup(ctx);
+ EVP_CIPHER_CTX_free(ctx);
decrypted->size = olen;
s_free(safepasswd);
pthread_mutex_unlock(&crypto_mutex);