From 2cabe4e99e16a0d92969414b23a8a065e5e41a72 Mon Sep 17 00:00:00 2001 From: Jingyi Hou Date: Fri, 24 May 2013 02:18:23 +0800 Subject: [PATCH] search_for_executable() fails to process last part of PATH if PATH does not end with ':' --- src/runtime/runtime.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/runtime/runtime.c b/src/runtime/runtime.c index 49c007b..cacc9c7 100644 --- a/src/runtime/runtime.c +++ b/src/runtime/runtime.c @@ -287,6 +287,18 @@ search_for_executable(const char *argv0) return search; } } + /* The above for-loop fails to process the last part of PATH if PATH does + * not end with ':'. We may consider appending an extra ':' to the end of + * SEARCH. -- houjingyi 2013-05-24 */ + if (start != NULL && *start != '\0') { + snprintf(buf, PATH_MAX + 1, "%s/%s", start, argv0); + if (access(buf, F_OK) == 0) { + free(search); + search = copied_realpath(buf); + free(buf); + return search; + } + } free(search); free(buf); -- 1.7.10.4