3
3
# name is unusually large. Any length between 4k and 16k trigger the bug
4
4
# when using glibc-2.4.90-9 or older.
6
# Copyright (C) 2006, 2009-2012 Free Software Foundation, Inc.
6
# Copyright (C) 2006, 2009-2013 Free Software Foundation, Inc.
7
7
# This file is free software; the Free Software Foundation
8
8
# gives unlimited permission to copy and/or distribute it,
9
9
# with or without modifications, as long as this notice is preserved.
61
char const *dir_name = "confdir-14B---";
63
62
size_t initial_cwd_len;
68
65
/* The bug is triggered when PATH_MAX < getpagesize (), so skip
69
66
this relatively expensive and invasive test if that's not true. */
70
if (getpagesize () <= PATH_MAX)
68
int bug_possible = PATH_MAX < getpagesize ();
73
75
cwd = getcwd (NULL, 0);
77
79
initial_cwd_len = strlen (cwd);
79
desired_depth = ((TARGET_LEN - 1 - initial_cwd_len)
80
/ (1 + strlen (dir_name)));
81
for (d = 0; d < desired_depth; d++)
83
if (mkdir (dir_name, S_IRWXU) < 0 || chdir (dir_name) < 0)
85
fail = 3; /* Unable to construct deep hierarchy. */
90
/* If libc has the bug in question, this invocation of getcwd
91
results in a failed assertion. */
92
cwd = getcwd (NULL, 0);
94
fail = 4; /* getcwd failed: it refuses to return a string longer
98
/* Call rmdir first, in case the above chdir failed. */
102
if (chdir ("..") < 0)
84
static char const dir_name[] = "confdir-14B---";
85
size_t desired_depth = ((TARGET_LEN - 1 - initial_cwd_len)
88
for (d = 0; d < desired_depth; d++)
90
if (mkdir (dir_name, S_IRWXU) < 0 || chdir (dir_name) < 0)
92
if (! (errno == ERANGE || errno == ENAMETOOLONG
94
fail = 3; /* Unable to construct deep hierarchy. */
99
/* If libc has the bug in question, this invocation of getcwd
100
results in a failed assertion. */
101
cwd = getcwd (NULL, 0);
103
fail = 4; /* getcwd didn't assert, but it failed for a long name
104
where the answer could have been learned. */
107
/* Call rmdir first, in case the above chdir failed. */
107
108
rmdir (dir_name);
111
if (chdir ("..") < 0)