1*2d0f481dSmgorny# $NetBSD: t_asan_global_buffer_overflow.sh,v 1.3 2019/01/29 20:02:34 mgorny Exp $ 270f257bcSkamil# 3*2d0f481dSmgorny# Copyright (c) 2018, 2019 The NetBSD Foundation, Inc. 470f257bcSkamil# All rights reserved. 570f257bcSkamil# 670f257bcSkamil# This code is derived from software contributed to The NetBSD Foundation 770f257bcSkamil# by Siddharth Muralee. 870f257bcSkamil# 970f257bcSkamil# Redistribution and use in source and binary forms, with or without 1070f257bcSkamil# modification, are permitted provided that the following conditions 1170f257bcSkamil# are met: 1270f257bcSkamil# 1. Redistributions of source code must retain the above copyright 1370f257bcSkamil# notice, this list of conditions and the following disclaimer. 1470f257bcSkamil# 2. Redistributions in binary form must reproduce the above copyright 1570f257bcSkamil# notice, this list of conditions and the following disclaimer in the 1670f257bcSkamil# documentation and/or other materials provided with the distribution. 1770f257bcSkamil# 1870f257bcSkamil# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 1970f257bcSkamil# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 2070f257bcSkamil# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2170f257bcSkamil# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 2270f257bcSkamil# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2370f257bcSkamil# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2470f257bcSkamil# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2570f257bcSkamil# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2670f257bcSkamil# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2770f257bcSkamil# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2870f257bcSkamil# POSSIBILITY OF SUCH DAMAGE. 2970f257bcSkamil# 3070f257bcSkamil 31*2d0f481dSmgornyASAN_CODE=' 3270f257bcSkamil#include <stdio.h> 3370f257bcSkamil#include <stdlib.h> 3470f257bcSkamilint arr[5] = {-1}; 35*2d0f481dSmgornyvoid foo(int); 36*2d0f481dSmgorny#ifndef PIC_MAIN 37*2d0f481dSmgornyvoid foo(int index) { arr[index] = 0; } 38*2d0f481dSmgorny#endif 39*2d0f481dSmgorny#ifndef PIC_FOO 4070f257bcSkamilint main(int argc, char **argv) {foo(argc + 5); printf("CHECK\n"); exit(0);} 41*2d0f481dSmgorny#endif 42*2d0f481dSmgorny' 4370f257bcSkamil 44*2d0f481dSmgornyasan_test_case global_buffer_overflow "Global Buffer Overflow example" \ 45*2d0f481dSmgorny global-buffer-overflow 4670f257bcSkamil 4770f257bcSkamilatf_init_test_cases() 4870f257bcSkamil{ 49*2d0f481dSmgorny asan_add_test_cases global_buffer_overflow 5070f257bcSkamil} 51