mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-29 18:27:29 +02:00
create buffer with structure copy and set fd after close
This commit is contained in:
@ -176,10 +176,20 @@ int wc_Sha256Copy(wc_Sha256* src, wc_Sha256* dst)
|
||||
}
|
||||
|
||||
XMEMCPY(dst, src, sizeof(wc_Sha256));
|
||||
|
||||
#ifdef WOLFSSL_AFALG_HASH_KEEP
|
||||
dst->msg = (byte*)XMALLOC(src->len, dst->heap, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
if (dst->msg == NULL) {
|
||||
return MEMORY_E;
|
||||
}
|
||||
XMEMCPY(dst->msg, src->msg, src->len);
|
||||
#endif
|
||||
|
||||
dst->rdFd = accept(src->rdFd, NULL, 0);
|
||||
dst->alFd = accept(src->alFd, NULL, 0);
|
||||
|
||||
if (dst->rdFd == -1 || dst->alFd == -1) {
|
||||
wc_Sha256Free(dst);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -2750,9 +2750,11 @@ void wc_Sha256Free(wc_Sha256* sha256)
|
||||
#if defined(WOLFSSL_AFALG_HASH)
|
||||
if (sha256->alFd > 0) {
|
||||
close(sha256->alFd);
|
||||
sha256->alFd = -1; /* avoid possible double close on socket */
|
||||
}
|
||||
if (sha256->rdFd > 0) {
|
||||
close(sha256->rdFd);
|
||||
sha256->rdFd = -1; /* avoid possible double close on socket */
|
||||
}
|
||||
|
||||
#if defined(WOLFSSL_AFALG_HASH_KEEP)
|
||||
|
Reference in New Issue
Block a user