From c4f2faf3019f2c41f9c3b2b8a73b4fe41e881328 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 13 Feb 2017 09:39:46 -0500 Subject: Don't atoi off the end of a buffer chunk. Fixes bug 20894; bugfix on 0.2.0.16-alpha. We already applied a workaround for this as 20834, so no need to freak out (unless you didn't apply 20384 yet). --- src/common/util.c | 13 +++++++++++++ src/common/util.h | 1 + 2 files changed, 14 insertions(+) (limited to 'src/common') diff --git a/src/common/util.c b/src/common/util.c index a7bce2ea6c..9024dbfe10 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -712,6 +712,19 @@ tor_strisnonupper(const char *s) return 1; } +/** Return true iff every character in s is whitespace space; else + * return false. */ +int +tor_strisspace(const char *s) +{ + while (*s) { + if (!TOR_ISSPACE(*s)) + return 0; + s++; + } + return 1; +} + /** As strcmp, except that either string may be NULL. The NULL string is * considered to be before any non-NULL string. */ int diff --git a/src/common/util.h b/src/common/util.h index 479fc8d610..6a743a6eac 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -186,6 +186,7 @@ void tor_strlower(char *s) ATTR_NONNULL((1)); void tor_strupper(char *s) ATTR_NONNULL((1)); int tor_strisprint(const char *s) ATTR_NONNULL((1)); int tor_strisnonupper(const char *s) ATTR_NONNULL((1)); +int tor_strisspace(const char *s); int strcmp_opt(const char *s1, const char *s2); int strcmpstart(const char *s1, const char *s2) ATTR_NONNULL((1,2)); int strcmp_len(const char *s1, const char *s2, size_t len) ATTR_NONNULL((1,2)); -- cgit v1.2.3-54-g00ecf