From d7a3431882878ae92862264d8b5b274053d1c171 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20Emil=20Schulz=20=C3=98stergaard?= Date: Tue, 3 Mar 2026 13:57:33 +0100 Subject: [PATCH] fix frame_clone_and_push_hdr: guard stack overflow at the push site Revert the incorrect argc > FRAME_STACK_MAX check added in db43211d2c80 argc counts total remaining argv (all subsequent tx/rx clauses), not per-frame stack entries, so 29+ tx clauses falsely tripped the limit. Instead, guard the actual array push in frame_clone_and_push_hdr(). --- src/ef-args.c | 5 ----- src/ef.c | 8 +++----- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/ef-args.c b/src/ef-args.c index 3a47590..d42bae6 100644 --- a/src/ef-args.c +++ b/src/ef-args.c @@ -9,11 +9,6 @@ int argc_frame(int argc, const char *argv[], frame_t *f) { int i, j, res, offset; hdr_t *h; - if(argc > FRAME_STACK_MAX) { - po("ERROR: Frame stack size is too big"); - return -1; - } - offset = 0; frame_reset(f); diff --git a/src/ef.c b/src/ef.c index 74a4842..81ee2c2 100644 --- a/src/ef.c +++ b/src/ef.c @@ -314,12 +314,10 @@ void frame_reset(frame_t *f) { } hdr_t *frame_clone_and_push_hdr(frame_t *f, hdr_t *h) { - hdr_t *new_hdr = hdr_clone(h); + if (f->stack_size >= FRAME_STACK_MAX) + return NULL; - f->stack[f->stack_size] = new_hdr; - f->stack_size ++; - - return new_hdr; + return f->stack[f->stack_size++] = hdr_clone(h); } int hdr_parse_fields(frame_t *frame, struct hdr *hdr, int offset,