From a61efe2cf0b10da82d529d8fced95a44facf8c5d Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 28 Sep 2021 16:59:01 -0700 Subject: Hardening utils (added *end param to avoid going past the end of unterminated strings) --- utils.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'utils.h') diff --git a/utils.h b/utils.h index 09b0c39..dae247b 100644 --- a/utils.h +++ b/utils.h @@ -12,8 +12,6 @@ #include #include -#include "match.h" - #define S1(x) #x #define S2(x) S1(x) #define __LOCATION__ __FILE__ ":" S2(__LINE__) @@ -48,15 +46,15 @@ DEFINE_CHECK_TYPE(_Bool, bool, b, b); #define streq(a, b) (strcmp(a, b) == 0) __attribute__((nonnull(1))) -char unescapechar(const char *escaped, const char **end); +char unescapechar(const char *escaped, const char **after, const char *end); __attribute__((pure, nonnull)) -const char *after_name(const char *str); +const char *after_name(const char *str, const char *end); __attribute__((pure, nonnull, returns_nonnull)) -const char *after_spaces(const char *str, bool skip_nl); +const char *after_spaces(const char *str, bool skip_nl, const char *end); __attribute__((nonnull)) -bool matchchar(const char **str, char c, bool skip_nl); +bool matchchar(const char **str, char c, bool skip_nl, const char *end); __attribute__((nonnull)) -bool matchstr(const char **str, const char *target, bool skip_nl); +bool matchstr(const char **str, const char *target, bool skip_nl, const char *end); __attribute__((nonnull)) void delete(void *p); -- cgit v1.2.3