mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	Merge branch 'obsd-master' into master
This commit is contained in:
		@@ -102,6 +102,11 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
 | 
			
		||||
	if (tmp != NULL) {
 | 
			
		||||
		name = format_single(item, tmp, c, NULL, NULL, NULL);
 | 
			
		||||
		newname = session_check_name(name);
 | 
			
		||||
		if (newname == NULL) {
 | 
			
		||||
			cmdq_error(item, "invalid session: %s", name);
 | 
			
		||||
			free(name);
 | 
			
		||||
			return (CMD_RETURN_ERROR);
 | 
			
		||||
		}
 | 
			
		||||
		free(name);
 | 
			
		||||
	}
 | 
			
		||||
	if (args_has(args, 'A')) {
 | 
			
		||||
@@ -134,8 +139,14 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
 | 
			
		||||
			prefix = xstrdup(sg->name);
 | 
			
		||||
		else if (groupwith != NULL)
 | 
			
		||||
			prefix = xstrdup(groupwith->name);
 | 
			
		||||
		else
 | 
			
		||||
		else {
 | 
			
		||||
			prefix = session_check_name(group);
 | 
			
		||||
			if (prefix == NULL) {
 | 
			
		||||
				cmdq_error(item, "invalid session group: %s",
 | 
			
		||||
				    group);
 | 
			
		||||
				goto fail;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Set -d if no client. */
 | 
			
		||||
 
 | 
			
		||||
@@ -53,6 +53,11 @@ cmd_rename_session_exec(struct cmd *self, struct cmdq_item *item)
 | 
			
		||||
 | 
			
		||||
	tmp = format_single_from_target(item, args->argv[0]);
 | 
			
		||||
	newname = session_check_name(tmp);
 | 
			
		||||
	if (newname == NULL) {
 | 
			
		||||
		cmdq_error(item, "invalid session: %s", tmp);
 | 
			
		||||
		free(tmp);
 | 
			
		||||
		return (CMD_RETURN_ERROR);
 | 
			
		||||
	}
 | 
			
		||||
	free(tmp);
 | 
			
		||||
	if (strcmp(newname, s->name) == 0) {
 | 
			
		||||
		free(newname);
 | 
			
		||||
 
 | 
			
		||||
@@ -235,6 +235,8 @@ session_check_name(const char *name)
 | 
			
		||||
{
 | 
			
		||||
	char	*copy, *cp, *new_name;
 | 
			
		||||
 | 
			
		||||
	if (*name == '\0')
 | 
			
		||||
		return (NULL);
 | 
			
		||||
	copy = xstrdup(name);
 | 
			
		||||
	for (cp = copy; *cp != '\0'; cp++) {
 | 
			
		||||
		if (*cp == ':' || *cp == '.')
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										15
									
								
								tmux.c
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								tmux.c
									
									
									
									
									
								
							@@ -207,16 +207,22 @@ make_label(const char *label, char **cause)
 | 
			
		||||
	free(paths);
 | 
			
		||||
 | 
			
		||||
	xasprintf(&base, "%s/tmux-%ld", path, (long)uid);
 | 
			
		||||
	if (mkdir(base, S_IRWXU) != 0 && errno != EEXIST)
 | 
			
		||||
	if (mkdir(base, S_IRWXU) != 0 && errno != EEXIST) {
 | 
			
		||||
		xasprintf(cause, "couldn't create directory %s (%s)", base,
 | 
			
		||||
		    strerror(errno));
 | 
			
		||||
		goto fail;
 | 
			
		||||
	if (lstat(base, &sb) != 0)
 | 
			
		||||
	}
 | 
			
		||||
	if (lstat(base, &sb) != 0) {
 | 
			
		||||
		xasprintf(cause, "couldn't read directory %s (%s)", base,
 | 
			
		||||
		    strerror(errno));
 | 
			
		||||
		goto fail;
 | 
			
		||||
	}
 | 
			
		||||
	if (!S_ISDIR(sb.st_mode)) {
 | 
			
		||||
		errno = ENOTDIR;
 | 
			
		||||
		xasprintf(cause, "%s is not a directory", base);
 | 
			
		||||
		goto fail;
 | 
			
		||||
	}
 | 
			
		||||
	if (sb.st_uid != uid || (sb.st_mode & S_IRWXO) != 0) {
 | 
			
		||||
		errno = EACCES;
 | 
			
		||||
		xasprintf(cause, "directory %s has unsafe permissions", base);
 | 
			
		||||
		goto fail;
 | 
			
		||||
	}
 | 
			
		||||
	xasprintf(&path, "%s/%s", base, label);
 | 
			
		||||
@@ -224,7 +230,6 @@ make_label(const char *label, char **cause)
 | 
			
		||||
	return (path);
 | 
			
		||||
 | 
			
		||||
fail:
 | 
			
		||||
	xasprintf(cause, "error creating %s (%s)", base, strerror(errno));
 | 
			
		||||
	free(base);
 | 
			
		||||
	return (NULL);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user