From 0b404d0ff40eb6eb6315e8d58e809d6adc5f34c8 Mon Sep 17 00:00:00 2001 From: midipix Date: Sep 13 2020 02:54:00 +0000 Subject: slbt_lconf_open(): exit loop upon reaching the top-level root directory. --- diff --git a/src/internal/slibtool_lconf_impl.c b/src/internal/slibtool_lconf_impl.c index 691536d..92aaa20 100644 --- a/src/internal/slibtool_lconf_impl.c +++ b/src/internal/slibtool_lconf_impl.c @@ -40,6 +40,7 @@ static int slbt_lconf_open( int fdparent; struct stat stcwd; struct stat stparent; + ino_t stinode; fdcwd = slbt_driver_fdcwd(dctx); fdlconfdir = fdcwd; @@ -53,6 +54,7 @@ static int slbt_lconf_open( return SLBT_SYSTEM_ERROR(dctx); fdlconf = openat(fdlconfdir,"libtool",O_RDONLY,0); + stinode = stcwd.st_ino; while (fdlconf < 0) { fdparent = openat(fdlconfdir,"../",O_DIRECTORY,0); @@ -72,8 +74,15 @@ static int slbt_lconf_open( dctx,SLBT_ERR_LCONF_OPEN); } + if (stparent.st_ino == stinode) { + close(fdparent); + return SLBT_CUSTOM_ERROR( + dctx,SLBT_ERR_LCONF_OPEN); + } + fdlconfdir = fdparent; fdlconf = openat(fdlconfdir,"libtool",O_RDONLY,0); + stinode = stparent.st_ino; } slbt_lconf_close(fdcwd,fdlconfdir);