mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2026-04-24 21:06:02 +03:00
[GH-ISSUE #2796] Inconsistent error handling in SHA256 digest functions (openssl_auth.cpp) #1300
Labels
No labels
bug
bug
dataloss
duplicate
enhancement
feature request
help wanted
invalid
need info
performance
pull-request
question
question
testing
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/s3fs-fuse#1300
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @CarstenGrohmann on GitHub (Jan 31, 2026).
Original GitHub issue: https://github.com/s3fs-fuse/s3fs-fuse/issues/2796
The digest functions using the old OpenSSL API (
s3fs_md5()ands3fs_sha256()) lack error handling. This creates silent failures where callers expect error detection but never receive it.The modern API usage was only added to the MD5 functions for OpenSSL 3.0.
Issues
No nullptr checks
EVP_get_digestbyname()andEVP_MD_CTX_create()can returnnullptron memory exhaustion. The code does not check for this, leading to undefined behavior.github.com/s3fs-fuse/s3fs-fuse@85cc411aaa/src/openssl_auth.cpp (L346-L347)No return value checks
The return values of
EVP_DigestInit_ex(),EVP_DigestUpdate(), andEVP_DigestFinal_ex()are ignored. These functions return 1 on success and 0 on failure.github.com/s3fs-fuse/s3fs-fuse@85cc411aaa/src/openssl_auth.cpp (L348-L351)No RAII
Manual resource management is used instead of
std::unique_ptrwith custom deleter, as done in the OpenSSL 3.0 version ofs3fs_md5().Deprecated API / Inconsistency
The MD5 functions have an OpenSSL 3.0 variant using modern API (
EVP_MD_CTX_new()/EVP_MD_CTX_free()), RAII, and proper error handling. The SHA256 functions still use the old API (EVP_MD_CTX_create()/EVP_MD_CTX_destroy()).github.com/s3fs-fuse/s3fs-fuse@85cc411aaa/src/openssl_auth.cpp (L347)Silent failure
The functions always return
true, even when OpenSSL operations fail. All callers have implemented error handling that checks the return value, but this code path is never executed:github.com/s3fs-fuse/s3fs-fuse@85cc411aaa/src/openssl_auth.cpp (L344-L355)Callers with dead error handling code:
github.com/s3fs-fuse/s3fs-fuse@85cc411aaa/src/curl.cpp (L2284-L2286)github.com/s3fs-fuse/s3fs-fuse@85cc411aaa/src/curl.cpp (L2350-L2352)github.com/s3fs-fuse/s3fs-fuse@85cc411aaa/src/common_auth.cpp (L43-L46)Question
Proposed Solution
Update
s3fs_sha256()ands3fs_sha256_fd()to match the style of the OpenSSL 3.0 MD5 functions:std::unique_ptrwith custom deleter for RAIIEVP_Digest*()functionsnullptrchecks for context creationEVP_MD_CTX_new()/EVP_MD_CTX_free())If you agree, I can create a PR for that.
@ggtakec commented on GitHub (Feb 7, 2026):
@CarstenGrohmann Thank you.
I still think it's best to maintain support for OpenSSL 1.1.x.
I also checked
openssl_auth.cpp, and in addition to the code you pointed out, I think it would be better to fix the calls toERR_load_crypto_strings,EVP_cleanup,ERR_free_strings, andOpenSSL_add_all_algorithms.github.com/s3fs-fuse/s3fs-fuse@90324ad669/src/openssl_auth.cpp (L55-L76)Calling these functions is no longer necessary in OpenSSL 1.1.0 and later.
I think it would be best to make the following changes. (This is for versions prior to 1.1.0, so you may want to remove it.)
I will wait for your PR, including the above.
Thanks in advance for your help.