Skip to content

Commit 44112b9

Browse files
fix check on return value
1 parent ec62e8b commit 44112b9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/we_aes_block.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static int we_aes_cbc_encrypt(we_AesBlock* aes, unsigned char *out,
151151
rc = wc_AesCbcEncrypt(&aes->aes, out, in, (unsigned int)len);
152152
if (rc != 0) {
153153
WOLFENGINE_ERROR_FUNC(WE_LOG_CIPHER, "wc_AesCbcEncrypt", rc);
154-
ret = 0;
154+
ret = -1;
155155
}
156156
WOLFENGINE_LEAVE(WE_LOG_CIPHER, "we_aes_cbc_encrypt", ret);
157157

@@ -180,11 +180,11 @@ static int we_aes_cbc_decrypt(we_AesBlock* aes, unsigned char *out,
180180

181181
/* padding is handled by OpenSSL before passed to we_aes_cbc_decrypt */
182182
rc = wc_AesCbcDecrypt(&aes->aes, out, in, (unsigned int)len);
183-
if (rc <= 0) {
184-
ret = -1;
183+
if (rc == 0) {
184+
ret = (int)len;
185185
}
186186
else {
187-
ret = (int)len;
187+
ret = -1;
188188
}
189189

190190
WOLFENGINE_LEAVE(WE_LOG_CIPHER, "we_aes_cbc_decrypt", ret);

0 commit comments

Comments
 (0)