#include <errno.h>
+#include "cycle-check.h"
#include "path-concat.h"
#include "stat-macros.h"
#include "xalloc.h"
char *rpath, *dest, *extra_buf = NULL;
const char *start, *end, *rpath_limit;
size_t extra_len = 0;
- int num_links = 0;
+ struct cycle_check_state cycle_state;
if (name == NULL)
{
dest = rpath + 1;
}
+ cycle_check_init (&cycle_state);
for (start = end = name; *start; start = end)
{
/* Skip sequence of multiple path-separators. */
char *buf;
size_t n, len;
-# ifdef MAXSYMLINKS
- if (++num_links > MAXSYMLINKS)
+ if (cycle_check (&cycle_state, &st))
{
__set_errno (ELOOP);
if (can_mode == CAN_MISSING)
else
goto error;
}
-# endif /* MAXSYMLINKS */
buf = xreadlink (rpath, st.st_size);
if (!buf)