1*86ee7a4eSmgorny# Copyright (c) 2018, 2019 The NetBSD Foundation, Inc.
25d8fa03fSkamil# All rights reserved.
35d8fa03fSkamil#
45d8fa03fSkamil# This code is derived from software contributed to The NetBSD Foundation
55d8fa03fSkamil# by Harry Pantazis.
65d8fa03fSkamil#
75d8fa03fSkamil# Redistribution and use in source and binary forms, with or without
85d8fa03fSkamil# modification, are permitted provided that the following conditions
95d8fa03fSkamil# are met:
105d8fa03fSkamil# 1. Redistributions of source code must retain the above copyright
115d8fa03fSkamil#    notice, this list of conditions and the following disclaimer.
125d8fa03fSkamil# 2. Redistributions in binary form must reproduce the above copyright
135d8fa03fSkamil#    notice, this list of conditions and the following disclaimer in the
145d8fa03fSkamil#    documentation and/or other materials provided with the distribution.
155d8fa03fSkamil#
165d8fa03fSkamil# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
175d8fa03fSkamil# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
185d8fa03fSkamil# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
195d8fa03fSkamil# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
205d8fa03fSkamil# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
215d8fa03fSkamil# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
225d8fa03fSkamil# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
235d8fa03fSkamil# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
245d8fa03fSkamil# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
255d8fa03fSkamil# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
265d8fa03fSkamil# POSSIBILITY OF SUCH DAMAGE.
275d8fa03fSkamil#
285d8fa03fSkamil
29*86ee7a4eSmgornyUBSAN_CODE='
305d8fa03fSkamil#include <stdio.h>
315d8fa03fSkamil#include <stdlib.h>
325d8fa03fSkamilvoid help(int);
33*86ee7a4eSmgorny#ifndef PIC_MAIN
345d8fa03fSkamilvoid help(int count) {volatile int val1 = count, val2 = count+1; volatile int arr[val1]; arr[val2] = count; }
35*86ee7a4eSmgorny#endif
36*86ee7a4eSmgorny#ifndef PIC_FOO
37*86ee7a4eSmgornyint main(int argc, char **argv) {help(argc); exit(0);}
38*86ee7a4eSmgorny#endif
39*86ee7a4eSmgorny'
405d8fa03fSkamil
41*86ee7a4eSmgornyubsan_test_case vla_out_of_bounds \
42*86ee7a4eSmgorny	"vla (Variable Length Array) out of bounds" "out of bounds"
435d8fa03fSkamil
445d8fa03fSkamilatf_init_test_cases()
455d8fa03fSkamil{
46*86ee7a4eSmgorny	ubsan_add_test_cases vla_out_of_bounds
475d8fa03fSkamil}
48