|
Packit Service |
4684c1 |
/*
|
|
Packit Service |
4684c1 |
* Copyright (C) 2017 Red Hat, Inc.
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* Author: Nikos Mavrogiannopoulos
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* This file is part of GnuTLS.
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* GnuTLS is free software; you can redistribute it and/or modify it
|
|
Packit Service |
4684c1 |
* under the terms of the GNU General Public License as published by
|
|
Packit Service |
4684c1 |
* the Free Software Foundation; either version 3 of the License, or
|
|
Packit Service |
4684c1 |
* (at your option) any later version.
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* GnuTLS is distributed in the hope that it will be useful, but
|
|
Packit Service |
4684c1 |
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
4684c1 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
4684c1 |
* General Public License for more details.
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* You should have received a copy of the GNU Lesser General Public License
|
|
Packit Service |
4684c1 |
* along with this program. If not, see <https://www.gnu.org/licenses/>
|
|
Packit Service |
4684c1 |
*/
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#ifdef HAVE_CONFIG_H
|
|
Packit Service |
4684c1 |
#include <config.h>
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#include <stdio.h>
|
|
Packit Service |
4684c1 |
#include <stdlib.h>
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#include <string.h>
|
|
Packit Service |
4684c1 |
#include <stdint.h>
|
|
Packit Service |
4684c1 |
#include <gnutls/gnutls.h>
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#include "utils.h"
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#define BUF_SIZE 128
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
void func1(void);
|
|
Packit Service |
4684c1 |
void func2(void);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static unsigned char *ptr;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
/* Checks whether gnutls_memset() call is being optimized
|
|
Packit Service |
4684c1 |
* out.
|
|
Packit Service |
4684c1 |
*/
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
void func1(void)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
unsigned char buf[BUF_SIZE];
|
|
Packit Service |
4684c1 |
ptr = buf;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_memset(buf, CHAR, sizeof(buf));
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
void func2(void)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
if (ptr[0] != CHAR || ptr[2] != CHAR || ptr[16] != CHAR)
|
|
Packit Service |
4684c1 |
fail("previous memset failed!\n");
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
void doit(void)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
#if defined(__has_feature)
|
|
Packit Service |
4684c1 |
# if __has_feature(address_sanitizer)
|
|
Packit Service |
4684c1 |
exit(77);
|
|
Packit Service |
4684c1 |
# endif
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#if __SANITIZE_ADDRESS__ == 1
|
|
Packit Service |
4684c1 |
exit(77);
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
func1();
|
|
Packit Service |
4684c1 |
func2();
|
|
Packit Service |
4684c1 |
success("memset test succeeded\n");
|
|
Packit Service |
4684c1 |
}
|