From eaa58d28dc7da9b2ef0d77f4c8e85aab55b71935 Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 16 Dec 2019 15:48:50 +0000 Subject: Instead of using large buffers in imsgs, add the data or path onto the end. --- server-client.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'server-client.c') diff --git a/server-client.c b/server-client.c index e6e4d8a9..fdedc35f 100644 --- a/server-client.c +++ b/server-client.c @@ -2024,10 +2024,10 @@ server_client_dispatch_read_data(struct client *c, struct imsg *imsg) struct msg_read_data *msg = imsg->data; size_t msglen = imsg->hdr.len - IMSG_HEADER_SIZE; struct client_file find, *cf; - void *bdata = msg->data; - size_t bsize = msg->size; + void *bdata = msg + 1; + size_t bsize = msglen - sizeof *msg; - if (msglen != sizeof *msg) + if (msglen < sizeof *msg) fatalx("bad MSG_READ_DATA size"); find.stream = msg->stream; if ((cf = RB_FIND(client_files, &c->files, &find)) == NULL) -- cgit From 1bdd4828bd0a13d6fb81c903078ad99ff2429b5d Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 16 Dec 2019 16:39:03 +0000 Subject: If /dev/fd/X is a symlink and realpath() expands symlinks, /dev/fd/X ends up pointing to the wrong place before it is passed to the client. The path is only used internally so there is no real need for realpath(), remove it and move the get_path function to file.c where all the callers are. --- server-client.c | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'server-client.c') diff --git a/server-client.c b/server-client.c index fdedc35f..ee7b4c70 100644 --- a/server-client.c +++ b/server-client.c @@ -2111,19 +2111,3 @@ server_client_get_cwd(struct client *c, struct session *s) return (home); return ("/"); } - -/* Resolve an absolute path or relative to client working directory. */ -char * -server_client_get_path(struct client *c, const char *file) -{ - char *path, resolved[PATH_MAX]; - - if (*file == '/') - path = xstrdup(file); - else - xasprintf(&path, "%s/%s", server_client_get_cwd(c, NULL), file); - if (realpath(path, resolved) == NULL) - return (path); - free(path); - return (xstrdup(resolved)); -} -- cgit