Fix padding error checking

Fixes a regression unfortunately introduced with 808a8eee
and not properly understood at the time
parent 09c146d4
......@@ -580,6 +580,7 @@ VCL_BLOB vmod_symmetric_decrypt(VRT_CTX,
gcry_error_t err = GPG_ERR_NO_ERROR;
gcry_cipher_hd_t *hd;
size_t blocklen;
ssize_t padlen;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(symmetric, VMOD_GCRYPT_SYMMETRIC_MAGIC);
......@@ -660,10 +661,16 @@ VCL_BLOB vmod_symmetric_decrypt(VRT_CTX,
blocklen);
goto fail;
}
plaintext->len =
padlen =
(unpadlenf[symmetric->padding])(plain,
ciphertext->len,
blocklen);
if (padlen < 0) {
VERR(ctx, "in %s.decrypt(): incorrect padding",
symmetric->vcl_name);
goto fail;
}
plaintext->len = padlen;
}
WS_Release(ctx->ws, plaintext->len);
return plaintext;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment