Skip to content

Commit 7de5f76

Browse files
committed
Check the return from "chdir" to avoid infinite loop
When autogen attempts to change to a new directory while processing a subdirectory, it can get into an infinite loop if that directory doesn't exist as it will remain in the top-level directory, see itself there (as "autogen.pl"), and re-execute itself. Check the return code on "chdir" and error out if it fails. Signed-off-by: Ralph Castain <[email protected]>
1 parent df9745a commit 7de5f76

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

autogen.pl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
55
# Copyright (c) 2013 Mellanox Technologies, Inc.
66
# All rights reserved.
7-
# Copyright (c) 2013-2014 Intel, Inc. All rights reserved.
7+
# Copyright (c) 2013-2020 Intel, Inc. All rights reserved.
88
# Copyright (c) 2015-2019 Research Organization for Information Science
99
# and Technology (RIST). All rights reserved.
1010
# Copyright (c) 2015 IBM Corporation. All rights reserved.
@@ -172,7 +172,10 @@ sub process_subdir {
172172
# Chdir to the subdir
173173
print "\n=== Processing subdir: $dir\n";
174174
my $start = Cwd::cwd();
175-
chdir($dir);
175+
my $check = chdir($dir);
176+
if (0 == $check) {
177+
my_die "Could not change to $dir\n";
178+
}
176179

177180
# Run an action depending on what we find in that subdir
178181
if (-x "autogen.pl") {

0 commit comments

Comments
 (0)