Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam
2026-04-28 12:01:08 +01:00
5 changed files with 41 additions and 10 deletions

View File

@@ -118,7 +118,7 @@ cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
size = args_percentage_and_expand(args, 'l', 0, INT_MAX, curval, size = args_percentage_and_expand(args, 'l', 0, INT_MAX, curval,
item, &cause); item, &cause);
} else if (args_has(args, 'p')) { } else if (args_has(args, 'p')) {
size = args_strtonum_and_expand(args, 'l', 0, 100, item, size = args_strtonum_and_expand(args, 'p', 0, 100, item,
&cause); &cause);
if (cause == NULL) if (cause == NULL)
size = curval * size / 100; size = curval * size / 100;

View File

@@ -128,6 +128,8 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmdq_item *item)
sigprocmask(SIG_SETMASK, &oldset, NULL); sigprocmask(SIG_SETMASK, &oldset, NULL);
cmdq_error(item, "fork error: %s", strerror(errno)); cmdq_error(item, "fork error: %s", strerror(errno));
close(pipe_fd[0]);
close(pipe_fd[1]);
free(cmd); free(cmd);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
case 0: case 0:

View File

@@ -198,8 +198,17 @@ cmd_run_shell_timer(__unused int fd, __unused short events, void* arg)
} }
if (job_run(cmd, 0, NULL, NULL, cdata->s, cdata->cwd, NULL, if (job_run(cmd, 0, NULL, NULL, cdata->s, cdata->cwd, NULL,
cmd_run_shell_callback, cmd_run_shell_free, cdata, cmd_run_shell_callback, cmd_run_shell_free, cdata,
cdata->flags, -1, -1) == NULL) cdata->flags, -1, -1) == NULL) {
if (cdata->item == NULL)
status_message_set(c, -1, 1, 0, 0,
"failed to run command: %s", cmd);
else {
cmdq_error(cdata->item,
"failed to run command: %s", cmd);
cmdq_continue(cdata->item);
}
cmd_run_shell_free(cdata); cmd_run_shell_free(cdata);
}
return; return;
} }

33
paste.c
View File

@@ -204,6 +204,7 @@ int
paste_rename(const char *oldname, const char *newname, char **cause) paste_rename(const char *oldname, const char *newname, char **cause)
{ {
struct paste_buffer *pb, *pb_new; struct paste_buffer *pb, *pb_new;
char *name;
if (cause != NULL) if (cause != NULL)
*cause = NULL; *cause = NULL;
@@ -219,23 +220,33 @@ paste_rename(const char *oldname, const char *newname, char **cause)
return (-1); return (-1);
} }
name = clean_name(newname, "");
if (name == NULL) {
if (cause != NULL)
xasprintf(cause, "invalid buffer name: %s", newname);
return (-1);
}
pb = paste_get_name(oldname); pb = paste_get_name(oldname);
if (pb == NULL) { if (pb == NULL) {
if (cause != NULL) if (cause != NULL)
xasprintf(cause, "no buffer %s", oldname); xasprintf(cause, "no buffer %s", oldname);
free(name);
return (-1); return (-1);
} }
pb_new = paste_get_name(newname); pb_new = paste_get_name(name);
if (pb_new == pb) if (pb_new == pb) {
free(name);
return (0); return (0);
}
if (pb_new != NULL) if (pb_new != NULL)
paste_free(pb_new); paste_free(pb_new);
RB_REMOVE(paste_name_tree, &paste_by_name, pb); RB_REMOVE(paste_name_tree, &paste_by_name, pb);
free(pb->name); free(pb->name);
pb->name = xstrdup(newname); pb->name = name;
if (pb->automatic) if (pb->automatic)
paste_num_automatic--; paste_num_automatic--;
@@ -244,7 +255,7 @@ paste_rename(const char *oldname, const char *newname, char **cause)
RB_INSERT(paste_name_tree, &paste_by_name, pb); RB_INSERT(paste_name_tree, &paste_by_name, pb);
notify_paste_buffer(oldname, 1); notify_paste_buffer(oldname, 1);
notify_paste_buffer(newname, 0); notify_paste_buffer(pb->name, 0);
return (0); return (0);
} }
@@ -257,6 +268,7 @@ int
paste_set(char *data, size_t size, const char *name, char **cause) paste_set(char *data, size_t size, const char *name, char **cause)
{ {
struct paste_buffer *pb, *old; struct paste_buffer *pb, *old;
char *newname;
if (cause != NULL) if (cause != NULL)
*cause = NULL; *cause = NULL;
@@ -276,9 +288,16 @@ paste_set(char *data, size_t size, const char *name, char **cause)
return (-1); return (-1);
} }
newname = clean_name(name, "");
if (newname == NULL) {
if (cause != NULL)
xasprintf(cause, "invalid buffer name: %s", name);
return (-1);
}
pb = xmalloc(sizeof *pb); pb = xmalloc(sizeof *pb);
pb->name = xstrdup(name); pb->name = newname;
pb->data = data; pb->data = data;
pb->size = size; pb->size = size;
@@ -288,13 +307,13 @@ paste_set(char *data, size_t size, const char *name, char **cause)
pb->created = time(NULL); pb->created = time(NULL);
if ((old = paste_get_name(name)) != NULL) if ((old = paste_get_name(pb->name)) != NULL)
paste_free(old); paste_free(old);
RB_INSERT(paste_name_tree, &paste_by_name, pb); RB_INSERT(paste_name_tree, &paste_by_name, pb);
RB_INSERT(paste_time_tree, &paste_by_time, pb); RB_INSERT(paste_time_tree, &paste_by_time, pb);
notify_paste_buffer(name, 0); notify_paste_buffer(pb->name, 0);
return (0); return (0);
} }

View File

@@ -5171,6 +5171,7 @@ window_copy_pipe_run(struct window_mode_entry *wme, struct session *s,
if (cmd != NULL && *cmd != '\0') { if (cmd != NULL && *cmd != '\0') {
job = job_run(cmd, 0, NULL, NULL, s, NULL, NULL, NULL, NULL, job = job_run(cmd, 0, NULL, NULL, s, NULL, NULL, NULL, NULL,
NULL, JOB_NOWAIT, -1, -1); NULL, JOB_NOWAIT, -1, -1);
if (job != NULL)
bufferevent_write(job_get_event(job), buf, *len); bufferevent_write(job_get_event(job), buf, *len);
} }
return (buf); return (buf);