On Wed, Jul 3, 2024 at 4:38 PM Dmitry V. Levin <l...@strace.io> wrote:
> On Tue, Jul 02, 2024 at 07:30:58PM +0200, Michal Sekletar wrote: > [...] > > +int > > +dwfl_set_sysroot (Dwfl *dwfl, const char *sysroot) > > +{ > > + if (!sysroot) > > + { > > + free (dwfl->sysroot); > > + dwfl->sysroot = NULL; > > + return 0; > > + } > > + > > + char *r, *s; > > + r = realpath (sysroot, NULL); > > + if (!r) > > + return -1; > > + > > + int rc; > > + struct stat sb; > > + > > + rc = stat (r, &sb); > > + if (rc < 0 || !S_ISDIR (sb.st_mode)) > > + { > > + errno = EINVAL; > > + return -1; > > + } > > + > > + rc = asprintf (&s, "%s/", r); > > There is a case when realpath() returns a path ending with '/': > when the path is "/". I'm mentioning this just in case, not sure whether > sysroot == "/" makes any sense at all, and whether this needs a special attention. > I think that should be fine, //sysroot should be equivalent to /sysroot, IOW, multiple slashes shouldn't cause any issues. Michal > > -- > ldv > >