1*49cdfc7eSAndroid Build Coastguard Worker // SPDX-License-Identifier: GPL-2.0-or-later 2*49cdfc7eSAndroid Build Coastguard Worker /* 3*49cdfc7eSAndroid Build Coastguard Worker * Copyright (C) 2018 Petr Vorel <[email protected]> 4*49cdfc7eSAndroid Build Coastguard Worker * Copyright (C) 2018 Michael Moese <[email protected]> 5*49cdfc7eSAndroid Build Coastguard Worker * 6*49cdfc7eSAndroid Build Coastguard Worker * cve-2018-1000001 realpath buffer underflow 7*49cdfc7eSAndroid Build Coastguard Worker * Based on the reproducer posted upstream so other copyrights may apply. 8*49cdfc7eSAndroid Build Coastguard Worker * Author: Dmitry V. Levin <[email protected]> 9*49cdfc7eSAndroid Build Coastguard Worker * LTP conversion from glibc source: Petr Vorel <[email protected]> 10*49cdfc7eSAndroid Build Coastguard Worker */ 11*49cdfc7eSAndroid Build Coastguard Worker 12*49cdfc7eSAndroid Build Coastguard Worker #include "tst_test.h" 13*49cdfc7eSAndroid Build Coastguard Worker 14*49cdfc7eSAndroid Build Coastguard Worker #include <errno.h> 15*49cdfc7eSAndroid Build Coastguard Worker #include <stdlib.h> 16*49cdfc7eSAndroid Build Coastguard Worker 17*49cdfc7eSAndroid Build Coastguard Worker #define CHROOT_DIR "cve-2018-1000001" 18*49cdfc7eSAndroid Build Coastguard Worker setup(void)19*49cdfc7eSAndroid Build Coastguard Workerstatic void setup(void) 20*49cdfc7eSAndroid Build Coastguard Worker { 21*49cdfc7eSAndroid Build Coastguard Worker SAFE_MKDIR(CHROOT_DIR, 0755); 22*49cdfc7eSAndroid Build Coastguard Worker SAFE_CHROOT(CHROOT_DIR); 23*49cdfc7eSAndroid Build Coastguard Worker } 24*49cdfc7eSAndroid Build Coastguard Worker run(void)25*49cdfc7eSAndroid Build Coastguard Workerstatic void run(void) 26*49cdfc7eSAndroid Build Coastguard Worker { 27*49cdfc7eSAndroid Build Coastguard Worker TST_EXP_FAIL_PTR_NULL(realpath(".", NULL), ENOENT); 28*49cdfc7eSAndroid Build Coastguard Worker } 29*49cdfc7eSAndroid Build Coastguard Worker 30*49cdfc7eSAndroid Build Coastguard Worker static struct tst_test test = { 31*49cdfc7eSAndroid Build Coastguard Worker .test_all = run, 32*49cdfc7eSAndroid Build Coastguard Worker .setup = setup, 33*49cdfc7eSAndroid Build Coastguard Worker .needs_root = 1, 34*49cdfc7eSAndroid Build Coastguard Worker .needs_tmpdir = 1, 35*49cdfc7eSAndroid Build Coastguard Worker .tags = (const struct tst_tag[]) { 36*49cdfc7eSAndroid Build Coastguard Worker {"CVE", "2018-1000001"}, 37*49cdfc7eSAndroid Build Coastguard Worker {} 38*49cdfc7eSAndroid Build Coastguard Worker } 39*49cdfc7eSAndroid Build Coastguard Worker }; 40