diff options
author | nicm <nicm> | 2019-03-14 23:34:41 +0000 |
---|---|---|
committer | nicm <nicm> | 2019-03-14 23:34:41 +0000 |
commit | 25e2e227913095c79d3c043da84db254c51f9c8c (patch) | |
tree | f8e36238a5cb6807dc4842f0470400f5a05270e3 | |
parent | 10d60faba5d06db707a752be47dbb12abd4b8168 (diff) | |
download | rtmux-25e2e227913095c79d3c043da84db254c51f9c8c.tar.gz rtmux-25e2e227913095c79d3c043da84db254c51f9c8c.tar.bz2 rtmux-25e2e227913095c79d3c043da84db254c51f9c8c.zip |
Add a limit on how far format_expand can recurse.
-rw-r--r-- | format.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -100,6 +100,9 @@ format_job_cmp(struct format_job *fj1, struct format_job *fj2) #define FORMAT_WINDOWS 0x100 #define FORMAT_PANES 0x200 +/* Limit on recursion. */ +#define FORMAT_LOOP_LIMIT 10 + /* Entry in format tree. */ struct format_entry { char *key; @@ -122,6 +125,7 @@ struct format_tree { u_int tag; int flags; time_t time; + u_int loop; RB_HEAD(format_entry_tree, format_entry) tree; }; @@ -1512,6 +1516,10 @@ format_expand(struct format_tree *ft, const char *fmt) if (fmt == NULL) return (xstrdup("")); + if (ft->loop == FORMAT_LOOP_LIMIT) + return (xstrdup("")); + ft->loop++; + len = 64; buf = xmalloc(len); off = 0; @@ -1606,6 +1614,8 @@ format_expand(struct format_tree *ft, const char *fmt) buf[off] = '\0'; log_debug("%s: '%s' -> '%s'", __func__, saved, buf); + + ft->loop--; return (buf); } |