From 2d8b6fcf23af749756dbb276ea1bf4e6871656a3 Mon Sep 17 00:00:00 2001 From: nicm Date: Sat, 12 Oct 2024 08:13:52 +0000 Subject: [PATCH 1/2] Do not rename a buffer to itself, GitHub issue 4181. --- paste.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/paste.c b/paste.c index ba9dd46b..559ace19 100644 --- a/paste.c +++ b/paste.c @@ -241,6 +241,8 @@ paste_rename(const char *oldname, const char *newname, char **cause) } pb_new = paste_get_name(newname); + if (pb_new == pb) + return (0); if (pb_new != NULL) paste_free(pb_new); From f8b56fdc3f1f45d0fc731f1e1a252c4fe318099b Mon Sep 17 00:00:00 2001 From: nicm Date: Sat, 12 Oct 2024 08:20:32 +0000 Subject: [PATCH 2/2] Call realpath on the source file to match -f on the command line, GitHub issue 4180. --- cmd-source-file.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd-source-file.c b/cmd-source-file.c index 38d56d31..67f353b9 100644 --- a/cmd-source-file.c +++ b/cmd-source-file.c @@ -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);