Download scripts/escape_invariant.diff from shawnnnliu/Hardened_SEC-Bench: direct link, hf CLI and curl.
- Browser
- Download file 1.05 kB
-
https://huggingface.co/datasets/shawnnnliu/Hardened_SEC-Bench/resolve/main/scripts/escape_invariant.diff
- Command line
-
hf download hf://datasets/shawnnnliu/Hardened_SEC-Bench/scripts/escape_invariant.diff
-
curl -L -o escape_invariant.diff https://huggingface.co/datasets/shawnnnliu/Hardened_SEC-Bench/resolve/main/scripts/escape_invariant.diff
1.05 kB
| diff --git a/programs/escape.c b/programs/escape.c | |
| --- a/programs/escape.c | |
| +++ b/programs/escape.c | |
| #include "common.h" | |
| #include "escape.h" | |
| +#include <unistd.h> | |
| + | |
| +/* ESCAPE-INVARIANT check (scripts/escape_invariant.diff, instrumentation | |
| + * only): strcat (d, s) appends s at the first NUL at or after d, and the | |
| + * escape loops then advance d by strlen (s), which is right only if the | |
| + * output is NUL-terminated at d. Report and exit before a strcat whose | |
| + * destination is not terminated at d. */ | |
| +static char * | |
| +escape_checked_strcat (char *d, const char *s, const char *func) | |
| +{ | |
| + if (*d != 0) | |
| + { | |
| + fprintf (stderr, | |
| + "ESCAPE-INVARIANT output not NUL-terminated at the strcat " | |
| + "position in %s (byte 0x%02x)\n", | |
| + func, (unsigned char)*d); | |
| + fflush (stderr); | |
| + _exit (86); | |
| + } | |
| + return strcat (d, s); | |
| +} | |
| +#define strcat(d, s) escape_checked_strcat ((d), (s), __func__) | |
| + | |
| char * ATTRIBUTE_MALLOC | |
| htmlescape (const char *restrict src, const int cp) | |
| { | |