Blame crypto/mem_clr.c

Packit c4476c
/*
Packit c4476c
 * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
Packit c4476c
 *
Packit c4476c
 * Licensed under the OpenSSL license (the "License").  You may not use
Packit c4476c
 * this file except in compliance with the License.  You can obtain a copy
Packit c4476c
 * in the file LICENSE in the source distribution or at
Packit c4476c
 * https://www.openssl.org/source/license.html
Packit c4476c
 */
Packit c4476c
Packit c4476c
#include <string.h>
Packit c4476c
#include <openssl/crypto.h>
Packit c4476c
Packit c4476c
/*
Packit c4476c
 * Pointer to memset is volatile so that compiler must de-reference
Packit c4476c
 * the pointer and can't assume that it points to any function in
Packit c4476c
 * particular (such as memset, which it then might further "optimize")
Packit c4476c
 */
Packit c4476c
typedef void *(*memset_t)(void *, int, size_t);
Packit c4476c
Packit c4476c
static volatile memset_t memset_func = memset;
Packit c4476c
Packit c4476c
void OPENSSL_cleanse(void *ptr, size_t len)
Packit c4476c
{
Packit c4476c
    memset_func(ptr, 0, len);
Packit c4476c
}