[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH for 6.2 12/49] bsd-user: implement path searching
From: |
Kyle Evans |
Subject: |
Re: [PATCH for 6.2 12/49] bsd-user: implement path searching |
Date: |
Sat, 7 Aug 2021 22:48:52 -0700 |
On Sat, Aug 7, 2021 at 10:11 PM Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> On 8/7/21 11:42 AM, Warner Losh wrote:
> > + path = g_strdup(p);
> > + if (path == NULL) {
>
> Only returns null when the input is null, which you've already eliminated.
>
> > +static bool find_in_path(char *path, const char *filename, char *retpath,
> > + size_t rpsize)
> > +{
> > + const char *d;
> > +
> > + while ((d = strsep(&path, ":")) != NULL) {
> > + if (*d == '\0') {
> > + d = ".";
> > + }
> > + if (snprintf(retpath, rpsize, "%s/%s", d, filename) >=
> > (int)rpsize) {
> > + continue;
> > + }
> > + if (is_there((const char *)retpath)) {
> > + return true;
> > + }
> > + }
> > + return false;
>
> Hmm. Fixed size retpath buffer isn't ideal.
> Any reason not to use g_find_program_in_path?
>
g_find_program_in_path may work well here, as well...
> I note that we don't search the path at all in linux-user/.
>
IIRC imgact_binmisc will have the resolved path but preserve argv as
it should have been were it not emulated, so we have to re-evaluate
the PATH search here because we try to be faithful to the context.
Thanks,
Kyle Evans
- [PATCH for 6.2 08/49] bsd-user: style nits: fix whitespace issues to be qemu standard, (continued)
- [PATCH for 6.2 08/49] bsd-user: style nits: fix whitespace issues to be qemu standard, Warner Losh, 2021/08/07
- [PATCH for 6.2 09/49] bsd-user: add license, Warner Losh, 2021/08/07
- [PATCH for 6.2 10/49] bsd-user: pass the bsd_param into loader_exec, Warner Losh, 2021/08/07
- [PATCH for 6.2 11/49] bsd-user: Fix calculation of size to allocate, Warner Losh, 2021/08/07
- [PATCH for 6.2 12/49] bsd-user: implement path searching, Warner Losh, 2021/08/07
- [PATCH for 6.2 13/49] bsd-user: Eliminate elf personality, Warner Losh, 2021/08/07
- [PATCH for 6.2 14/49] bsd-user: remove a.out support, Warner Losh, 2021/08/07
- [PATCH for 6.2 15/49] bsd-user: TARGET_NGROUPS unused in this file, remove, Warner Losh, 2021/08/07
- [PATCH for 6.2 16/49] bsd-user: elfload: simplify bswap a bit., Warner Losh, 2021/08/07