|
From: | Richard Henderson |
Subject: | Re: [PATCH for 6.2 12/49] bsd-user: implement path searching |
Date: | Sat, 7 Aug 2021 19:11:16 -1000 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 |
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? I note that we don't search the path at all in linux-user/. r~
[Prev in Thread] | Current Thread | [Next in Thread] |