1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

lib:util: Check memset_s() error code in talloc_keep_secret_destructor()

Panic if memset_s() fails.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Joseph Sutton 2022-08-02 14:35:33 +12:00 committed by Andrew Bartlett
parent 65c473d4a5
commit 03a50d8f7d

View File

@ -22,13 +22,26 @@
static int talloc_keep_secret_destructor(void *ptr)
{
int ret;
size_t size = talloc_get_size(ptr);
if (unlikely(size == 0)) {
return 0;
}
memset_s(ptr, size, 0, size);
ret = memset_s(ptr, size, 0, size);
if (unlikely(ret != 0)) {
char *msg = NULL;
int ret2;
ret2 = asprintf(&msg,
"talloc_keep_secret_destructor: memset_s() failed: %s",
strerror(ret));
if (ret2 != -1) {
smb_panic(msg);
} else {
smb_panic("talloc_keep_secret_destructor: memset_s() failed");
}
}
return 0;
}