Fix error handling at openssl_strerror_r
When bufsize == 0, openssl_strerror_r should return 0 (if _GNU_SOURCE is defined),
to be consistent with non-_GNU_SOURCE variants, which exhibit the same behavior.
Fix a few cases, where the return value of openssl_strerror_r was ignored.
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/9163)
(cherry picked from commit e7a4682d0b
)
This commit is contained in:
parent
10bf506819
commit
2459dc1bd0
2 changed files with 7 additions and 7 deletions
|
@ -231,7 +231,7 @@ int openssl_strerror_r(int errnum, char *buf, size_t buflen)
|
|||
* buf is left unused.
|
||||
*/
|
||||
err = strerror_r(errnum, buf, buflen);
|
||||
if (err == NULL)
|
||||
if (err == NULL || buflen == 0)
|
||||
return 0;
|
||||
/*
|
||||
* If err is statically allocated, err != buf and we need to copy the data.
|
||||
|
|
|
@ -860,9 +860,9 @@ static OSSL_STORE_LOADER_CTX *file_open(const OSSL_STORE_LOADER *loader,
|
|||
if (ctx->_.dir.last_entry == NULL) {
|
||||
if (ctx->_.dir.last_errno != 0) {
|
||||
char errbuf[256];
|
||||
errno = ctx->_.dir.last_errno;
|
||||
openssl_strerror_r(errno, errbuf, sizeof(errbuf));
|
||||
OSSL_STOREerr(OSSL_STORE_F_FILE_OPEN, ERR_R_SYS_LIB);
|
||||
errno = ctx->_.dir.last_errno;
|
||||
if (openssl_strerror_r(errno, errbuf, sizeof(errbuf)))
|
||||
ERR_add_error_data(1, errbuf);
|
||||
goto err;
|
||||
}
|
||||
|
@ -1260,10 +1260,10 @@ static OSSL_STORE_INFO *file_load(OSSL_STORE_LOADER_CTX *ctx,
|
|||
if (!ctx->_.dir.end_reached) {
|
||||
char errbuf[256];
|
||||
assert(ctx->_.dir.last_errno != 0);
|
||||
OSSL_STOREerr(OSSL_STORE_F_FILE_LOAD, ERR_R_SYS_LIB);
|
||||
errno = ctx->_.dir.last_errno;
|
||||
ctx->errcnt++;
|
||||
openssl_strerror_r(errno, errbuf, sizeof(errbuf));
|
||||
OSSL_STOREerr(OSSL_STORE_F_FILE_LOAD, ERR_R_SYS_LIB);
|
||||
if (openssl_strerror_r(errno, errbuf, sizeof(errbuf)))
|
||||
ERR_add_error_data(1, errbuf);
|
||||
}
|
||||
return NULL;
|
||||
|
|
Loading…
Reference in a new issue