mirror of
https://github.com/tmux/tmux.git
synced 2026-10-10 20:24:21 +00:00
Merge and fix conflicts.
This commit is contained in:
28
format.c
28
format.c
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: format.c,v 1.421 2026/09/28 16:52:55 nicm Exp $ */
|
||||
/* $OpenBSD: format.c,v 1.425 2026/10/05 10:59:37 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||
@@ -88,9 +88,12 @@ format_job_cmp(struct format_job *fj1, struct format_job *fj2)
|
||||
/* Maximum pad and trim width. */
|
||||
#define FORMAT_MAX_WIDTH 10000
|
||||
|
||||
/* Maximum repeat size. */
|
||||
/* Maximum repeat count. */
|
||||
#define FORMAT_MAX_REPEAT 10000
|
||||
|
||||
/* Maximum repeat result size in bytes. */
|
||||
#define FORMAT_MAX_REPEAT_SIZE 65536
|
||||
|
||||
/* Maximum precision. */
|
||||
#define FORMAT_MAX_PRECISION 100
|
||||
|
||||
@@ -1676,7 +1679,7 @@ format_cb_client_last_session(struct format_tree *ft)
|
||||
static void *
|
||||
format_cb_client_name(struct format_tree *ft)
|
||||
{
|
||||
if (ft->c != NULL)
|
||||
if (ft->c != NULL && ft->c->name != NULL)
|
||||
return (xstrdup(ft->c->name));
|
||||
return (NULL);
|
||||
}
|
||||
@@ -1739,7 +1742,7 @@ format_cb_client_termfeatures(struct format_tree *ft)
|
||||
static void *
|
||||
format_cb_client_termname(struct format_tree *ft)
|
||||
{
|
||||
if (ft->c != NULL)
|
||||
if (ft->c != NULL && ft->c->term_name != NULL)
|
||||
return (xstrdup(ft->c->term_name));
|
||||
return (NULL);
|
||||
}
|
||||
@@ -1760,7 +1763,7 @@ format_cb_client_termtype(struct format_tree *ft)
|
||||
static void *
|
||||
format_cb_client_tty(struct format_tree *ft)
|
||||
{
|
||||
if (ft->c != NULL)
|
||||
if (ft->c != NULL && ft->c->ttyname != NULL)
|
||||
return (xstrdup(ft->c->ttyname));
|
||||
return (NULL);
|
||||
}
|
||||
@@ -4565,8 +4568,8 @@ format_pretty_time(time_t t, int seconds)
|
||||
now = t;
|
||||
age = now - t;
|
||||
|
||||
localtime_r(&now, &now_tm);
|
||||
localtime_r(&t, &tm);
|
||||
if (localtime_r(&now, &now_tm) == NULL || localtime_r(&t, &tm) == NULL)
|
||||
return (xstrdup(""));
|
||||
|
||||
/* Last 24 hours. */
|
||||
if (age < 24 * 3600) {
|
||||
@@ -4737,10 +4740,12 @@ found:
|
||||
found = format_pretty_time(t, 0);
|
||||
else {
|
||||
if (time_format != NULL) {
|
||||
localtime_r(&t, &tm);
|
||||
if (localtime_r(&t, &tm) == NULL)
|
||||
return (NULL);
|
||||
format_strftime(s, sizeof s, time_format, &tm);
|
||||
} else {
|
||||
ctime_r(&t, s);
|
||||
if (ctime_r(&t, s) == NULL)
|
||||
return (NULL);
|
||||
s[strcspn(s, "\n")] = '\0';
|
||||
}
|
||||
found = xstrdup(s);
|
||||
@@ -4871,6 +4876,9 @@ format_skip1(struct format_expand_state *es, const char *s, const char *end)
|
||||
int brackets = 0;
|
||||
u_int check = 0;
|
||||
|
||||
if (es != NULL && !format_check_time(es, NULL))
|
||||
return (NULL);
|
||||
|
||||
for (; *s != '\0'; s++) {
|
||||
if (es != NULL && !format_check_time(es, &check))
|
||||
return (NULL);
|
||||
@@ -6472,7 +6480,7 @@ format_replace(struct format_expand_state *es, const char *key, size_t keylen,
|
||||
value = xstrdup("");
|
||||
else {
|
||||
n = strlen(left);
|
||||
if (n != 0 && nrep > (SIZE_MAX - 1) / n) {
|
||||
if (n != 0 && nrep > FORMAT_MAX_REPEAT_SIZE / n) {
|
||||
format_log(es, "repeat is too long: %s", copy);
|
||||
value = xstrdup("");
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user