11.5Smgorny# Copyright (c) 2018, 2019 The NetBSD Foundation, Inc.
21.1Skamil# All rights reserved.
31.1Skamil#
41.1Skamil# This code is derived from software contributed to The NetBSD Foundation
51.1Skamil# by Harry Pantazis.
61.1Skamil#
71.1Skamil# Redistribution and use in source and binary forms, with or without
81.1Skamil# modification, are permitted provided that the following conditions
91.1Skamil# are met:
101.1Skamil# 1. Redistributions of source code must retain the above copyright
111.1Skamil#    notice, this list of conditions and the following disclaimer.
121.1Skamil# 2. Redistributions in binary form must reproduce the above copyright
131.1Skamil#    notice, this list of conditions and the following disclaimer in the
141.1Skamil#    documentation and/or other materials provided with the distribution.
151.1Skamil#
161.1Skamil# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
171.1Skamil# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
181.1Skamil# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
191.1Skamil# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
201.1Skamil# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
211.1Skamil# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
221.1Skamil# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
231.1Skamil# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
241.1Skamil# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
251.1Skamil# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
261.1Skamil# POSSIBILITY OF SUCH DAMAGE.
271.1Skamil#
281.1Skamil
291.5SmgornyUBSAN_CODE='
301.1Skamil#include <stdio.h>
311.1Skamil#include <stdlib.h>
321.1Skamilvoid help(int);
331.5Smgorny#ifndef PIC_MAIN
341.5Smgornyvoid help(int count) {volatile int val1 = count, val2 = count+1; volatile int arr[val1]; arr[val2] = count; }
351.5Smgorny#endif
361.5Smgorny#ifndef PIC_FOO
371.1Skamilint main(int argc, char **argv) {help(argc); exit(0);}
381.5Smgorny#endif
391.5Smgorny'
401.1Skamil
411.5Smgornyubsan_test_case vla_out_of_bounds \
421.5Smgorny	"vla (Variable Length Array) out of bounds" "out of bounds"
431.1Skamil
441.1Skamilatf_init_test_cases()
451.1Skamil{
461.5Smgorny	ubsan_add_test_cases vla_out_of_bounds
471.1Skamil}
48