aboutsummaryrefslogtreecommitdiff
path: root/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'common.c')
-rw-r--r--common.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/common.c b/common.c
index f9a8944..0fc55d5 100644
--- a/common.c
+++ b/common.c
@@ -591,11 +591,22 @@ int mstat_find_program(const char *name, char *where) {
path = strdup(pathtmp);
path_orig = path;
+ if (!strncmp(name, "./", 2)) {
+ strncpy(nametmp, realpath(name, NULL), PATH_MAX - 1);
+ if (access(nametmp, X_OK) < 0) {
+ return 1;
+ }
+ if (where) {
+ strcpy(where, nametmp);
+ }
+ return 0;
+ }
+
char *last_element = strrchr(name, '/');
if (last_element) {
- strncpy(nametmp, last_element + 1, sizeof(nametmp) - 1);
+ strncat(nametmp, last_element + 1, sizeof(nametmp) - 1);
} else {
- strncpy(nametmp, name, sizeof(nametmp) - 1);
+ strncat(nametmp, name, sizeof(nametmp) - 1);
}
while ((token = strsep(&path, ":")) != NULL) {