@@ -293,8 +293,10 @@ openssl_enc(const EVP_CIPHER * cipher, const unsigned char *key, const unsigned
293
293
ctx = EVP_CIPHER_CTX_new ();
294
294
if (ctx == NULL )
295
295
goto out ;
296
- EVP_EncryptInit_ex (ctx , cipher , NULL , key , iv_tmp );
297
- EVP_CIPHER_CTX_set_padding (ctx , 0 );
296
+
297
+ if (!EVP_EncryptInit_ex (ctx , cipher , NULL , key , iv_tmp ) ||
298
+ !EVP_CIPHER_CTX_set_padding (ctx , 0 ))
299
+ goto out ;
298
300
299
301
if (!EVP_EncryptUpdate (ctx , output , & outl , input , (int )length ))
300
302
goto out ;
@@ -304,8 +306,7 @@ openssl_enc(const EVP_CIPHER * cipher, const unsigned char *key, const unsigned
304
306
305
307
r = SC_SUCCESS ;
306
308
out :
307
- if (ctx )
308
- EVP_CIPHER_CTX_free (ctx );
309
+ EVP_CIPHER_CTX_free (ctx );
309
310
return r ;
310
311
}
311
312
@@ -323,8 +324,10 @@ openssl_dec(const EVP_CIPHER * cipher, const unsigned char *key, const unsigned
323
324
ctx = EVP_CIPHER_CTX_new ();
324
325
if (ctx == NULL )
325
326
goto out ;
326
- EVP_DecryptInit_ex (ctx , cipher , NULL , key , iv_tmp );
327
- EVP_CIPHER_CTX_set_padding (ctx , 0 );
327
+
328
+ if (!EVP_DecryptInit_ex (ctx , cipher , NULL , key , iv_tmp ) ||
329
+ !EVP_CIPHER_CTX_set_padding (ctx , 0 ))
330
+ goto out ;
328
331
329
332
if (!EVP_DecryptUpdate (ctx , output , & outl , input , (int )length ))
330
333
goto out ;
@@ -334,8 +337,7 @@ openssl_dec(const EVP_CIPHER * cipher, const unsigned char *key, const unsigned
334
337
335
338
r = SC_SUCCESS ;
336
339
out :
337
- if (ctx )
338
- EVP_CIPHER_CTX_free (ctx );
340
+ EVP_CIPHER_CTX_free (ctx );
339
341
return r ;
340
342
}
341
343
0 commit comments