From ea6cb2d3bb1796aef2c195079fe91311a43f4b82 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Tue, 4 Jun 2024 13:09:32 -0400 Subject: implement jmp_buf tracking and disallow setjmp macro suppression --- src/setjmp/setjmp.c | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-) (limited to 'src/setjmp/setjmp.c') diff --git a/src/setjmp/setjmp.c b/src/setjmp/setjmp.c index 091f0993..3c8a199c 100644 --- a/src/setjmp/setjmp.c +++ b/src/setjmp/setjmp.c @@ -1,37 +1,16 @@ #include -#include #include "_safety.h" -/** save program state **/ +#undef setjmp -int setjmp(jmp_buf env) +int setjmp(jmp_buf jb) { - extern int ___setjmp(jmp_buf); - SIGNAL_SAFE(0); - memset(env, 0, sizeof(jmp_buf)); - return ___setjmp(env); + (void)jb; + UNDEFINED("The setjmp() macro has been suppressed to access an actual function"); + return 0; } -CHECK_1(int, 0, setjmp, jmp_buf) - -/*** -saves the current state of the calling environment -in the TYPEDEF(jmp_buf) ARGUMENT(env). -***/ - /* -RETURN(0, the environment has been saved by THIS()) -RETURN(NONZERO, the environment has been restored by FUNCTION(longjmp)) - -CONSTRAINT: entire controlling expression of a selection or iteration statement -CONSTRAINT: one operand of a relational or equality operator which is the entire controlling expression of a selction or iteration statement -CONSTRAINT: the operand of a unary ! as the entire controlling expression of a selection or iteration statement -CONSTRAINT: an entire expression statement - -UNSPECIFIED(Whether THIS() is a macro or identifier with external linkage) - -UNDEFINED(A macro definition of THIS() is suppressed in order to access an actual function) -UNDEFINED(A program defines an external identifier named LITERAL(setjmp)) - -STDC(1) +SIGNAL_SAFE(0) +STDC(0) */ -- cgit v1.2.1