Call realpath on the source file to match -f on the command line, GitHub
authornicm <nicm@openbsd.org>
Sat, 12 Oct 2024 08:20:32 +0000 (08:20 +0000)
committernicm <nicm@openbsd.org>
Sat, 12 Oct 2024 08:20:32 +0000 (08:20 +0000)
issue 4180.

usr.bin/tmux/cmd-source-file.c

index 83c29bf..01e4a8a 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-source-file.c,v 1.54 2023/09/15 06:31:49 nicm Exp $ */
+/* $OpenBSD: cmd-source-file.c,v 1.55 2024/10/12 08:20:32 nicm Exp $ */
 
 /*
  * Copyright (c) 2008 Tiago Cunha <me@tiagocunha.org>
@@ -122,6 +122,14 @@ cmd_source_file_done(struct client *c, const char *path, int error,
 static void
 cmd_source_file_add(struct cmd_source_file_data *cdata, const char *path)
 {
+       char    resolved[PATH_MAX];
+
+       if (realpath(path, resolved) == NULL) {
+               log_debug("%s: realpath(\"%s\") failed: %s", __func__,
+                       path, strerror(errno));
+       } else
+               path = resolved;
+
        log_debug("%s: %s", __func__, path);
        cdata->files = xreallocarray(cdata->files, cdata->nfiles + 1,
            sizeof *cdata->files);