keepalived: use EVP API instead of deprecated MD5 - #1062
Open
ytwang0320 wants to merge 2 commits into
Open
Conversation
Contributor
|
本 PR 标题是 keepalived MD5→EVP,但 NAT64/NAT46 快转路径这个改动和本PR无关,建议拆分单独的PR |
Contributor
|
用codex评审,供参考: 🔴 必须修 1. 2. req->context = EVP_MD_CTX_new();
EVP_DigestInit_ex(req->context, EVP_md5(), NULL); // req->context 可能为 NULL
分配失败时 EVP_DigestInit_ex(NULL, ...)/后续 EVP_DigestUpdate(NULL, ...) 会解引用 NULL 导致
健康检查进程崩溃。vrrp_ipsecah.c 里已经做了判空,这里应保持一致:判空 + 检查 EVP_DigestInit_ex() == 1,
失败则记录日志/置检查失败并释放上下文。
🟡 建议修
3. tk[EVP_MD_size(EVP_md5())] 引入了变长数组(VLA)
vrrp_ipsecah.c:
unsigned char tk[EVP_MD_size(EVP_md5())]; // 运行时表达式 → VLA
原来是固定的 tk[MD5_DIGEST_LENGTH]。VLA 是退步,且在 -Wvla -Werror 下会编译失败。
建议改回 MD5_DIGEST_LENGTH(该宏未被弃用)、16,或 EVP_MAX_MD_SIZE。
4. EVP_DigestUpdate() / EVP_DigestFinal_ex() 返回值未检查
check_http.c、check_ssl.c、vrrp_ipsecah.c 多处未检查这两个调用的返回值
(vrrp_ipsecah.c 仅检查了 init)。失败时会静默比对部分/未初始化的摘要,或发出错误的认证值。建议统一检查。
5. OpenSSL 版本基线提高,请确认/注明
EVP_MD_CTX_new()/EVP_MD_CTX_free() 需要 OpenSSL ≥ 1.1.0。若 vendored keepalived 仍需支持更老的
OpenSSL,请更新 configure/兼容代码,或在文档中注明新的最低版本要求。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.