diff options
author | Nick Wellnhofer <wellnhofer@aevum.de> | 2015-06-07 16:54:37 +0200 |
---|---|---|
committer | Nick Wellnhofer <wellnhofer@aevum.de> | 2015-06-07 21:42:15 +0200 |
commit | bef240d45b5eda3a584ca1a495f54cb17ff8895f (patch) | |
tree | 2f51762317d378dd20ed991daef49d2a3cf86f89 /src/buffer.h | |
parent | 7382fd5eba48107a8190bd2d6232cc3b6e20d8fc (diff) |
Check for overflow in S_parser_feed
Guard against too large chunks passed via the API.
Diffstat (limited to 'src/buffer.h')
-rw-r--r-- | src/buffer.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/buffer.h b/src/buffer.h index 9c850e4..f9696e0 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -74,6 +74,14 @@ void cmark_strbuf_unescape(cmark_strbuf *s); /* Print error and abort. */ void cmark_strbuf_overflow_err(void); +static inline bufsize_t +cmark_strbuf_check_bufsize(size_t size) { + if (size > BUFSIZE_MAX) { + cmark_strbuf_overflow_err(); + } + return (bufsize_t)size; +} + #ifdef __cplusplus } #endif |