From f750556078b7c010e9b30d85f3257ff473741374 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 10 Jun 2021 07:58:08 +0000 Subject: [PATCH] Bump FORMAT_LOOOP_LIMIT and add a log message when hit, GitHub issue 2715. --- usr.bin/tmux/format.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/usr.bin/tmux/format.c b/usr.bin/tmux/format.c index 4b25ed5b9a2..a9d6ac9cb77 100644 --- a/usr.bin/tmux/format.c +++ b/usr.bin/tmux/format.c @@ -1,4 +1,4 @@ -/* $OpenBSD: format.c,v 1.285 2021/06/10 07:57:06 nicm Exp $ */ +/* $OpenBSD: format.c,v 1.286 2021/06/10 07:58:08 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott @@ -103,7 +103,7 @@ format_job_cmp(struct format_job *fj1, struct format_job *fj2) #define FORMAT_CHARACTER 0x10000 /* Limit on recursion. */ -#define FORMAT_LOOP_LIMIT 10 +#define FORMAT_LOOP_LIMIT 100 /* Format expand flags. */ #define FORMAT_EXPAND_TIME 0x1 @@ -3991,7 +3991,7 @@ format_replace_expression(struct format_modifier *mexp, result = (mleft < mright); break; case LESS_THAN_EQUAL: - result = (mleft >= mright); + result = (mleft <= mright); break; } if (use_fp) @@ -4441,8 +4441,10 @@ format_expand1(struct format_expand_state *es, const char *fmt) if (fmt == NULL || *fmt == '\0') return (xstrdup("")); - if (es->loop == FORMAT_LOOP_LIMIT) + if (es->loop == FORMAT_LOOP_LIMIT) { + format_log(es, "reached loop limit (%u)", FORMAT_LOOP_LIMIT); return (xstrdup("")); + } es->loop++; format_log(es, "expanding format: %s", fmt); -- 2.20.1