mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 09:26:05 +00:00 
			
		
		
		
	Sync OpenBSD patchset 181:
Make all messages sent between the client and server fixed size. This is the first of two changes to make the protocol more resilient and less sensitive to other changes in the code, particularly with commands. The client now packs argv into a buffer and sends it to the server for parsing, rather than doing it itself and sending the parsed command data. As a side-effect this also removes a lot of now-unused command marshalling code. Mixing a server without this change and a client with or vice versa will cause tmux to hang or crash, please ensure that tmux is entirely killed before upgrading.
This commit is contained in:
		
							
								
								
									
										21
									
								
								client.c
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								client.c
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
			
		||||
/* $Id: client.c,v 1.56 2009-07-23 23:47:23 tcunha Exp $ */
 | 
			
		||||
/* $Id: client.c,v 1.57 2009-07-28 22:12:16 tcunha Exp $ */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
			
		||||
@@ -44,8 +44,7 @@ client_init(char *path, struct client_ctx *cctx, int cmdflags, int flags)
 | 
			
		||||
	struct winsize			ws;
 | 
			
		||||
	size_t				size;
 | 
			
		||||
	int				mode;
 | 
			
		||||
	struct buffer		       *b;
 | 
			
		||||
	char			       *name;
 | 
			
		||||
	char			       *name, *term;
 | 
			
		||||
#ifdef HAVE_SETPROCTITLE
 | 
			
		||||
	char		 		rpathbuf[MAXPATHLEN];
 | 
			
		||||
#endif
 | 
			
		||||
@@ -107,20 +106,24 @@ server_started:
 | 
			
		||||
		data.flags = flags;
 | 
			
		||||
		data.sx = ws.ws_col;
 | 
			
		||||
		data.sy = ws.ws_row;
 | 
			
		||||
		*data.tty = '\0';
 | 
			
		||||
 | 
			
		||||
		if (getcwd(data.cwd, sizeof data.cwd) == NULL)
 | 
			
		||||
			*data.cwd = '\0';
 | 
			
		||||
 | 
			
		||||
		*data.term = '\0';
 | 
			
		||||
		if ((term = getenv("TERM")) != NULL) {
 | 
			
		||||
			if (strlcpy(data.term,
 | 
			
		||||
			    term, sizeof data.term) >= sizeof data.term)
 | 
			
		||||
				*data.term = '\0';
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		*data.tty = '\0';
 | 
			
		||||
		if ((name = ttyname(STDIN_FILENO)) == NULL)
 | 
			
		||||
			fatal("ttyname failed");
 | 
			
		||||
		if (strlcpy(data.tty, name, sizeof data.tty) >= sizeof data.tty)
 | 
			
		||||
			fatalx("ttyname failed");
 | 
			
		||||
 | 
			
		||||
		b = buffer_create(BUFSIZ);
 | 
			
		||||
		cmd_send_string(b, getenv("TERM"));
 | 
			
		||||
		client_write_server2(cctx, MSG_IDENTIFY,
 | 
			
		||||
		    &data, sizeof data, BUFFER_OUT(b), BUFFER_USED(b));
 | 
			
		||||
		buffer_destroy(b);
 | 
			
		||||
		client_write_server(cctx, MSG_IDENTIFY, &data, sizeof data);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return (0);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user