diff options
author | Michael Cahill <michael.cahill@wiredtiger.com> | 2012-06-20 12:37:42 +1000 |
---|---|---|
committer | Michael Cahill <michael.cahill@wiredtiger.com> | 2012-06-20 12:37:42 +1000 |
commit | e426c6c393523cd232402a8101b195152d6ef711 (patch) | |
tree | 523adce8c9daec08a9b43035baaa430330af6deb /src/config/config.c | |
parent | 55f9b3f4376041552b525aca994df4a9dcd59b49 (diff) | |
download | mongo-e426c6c393523cd232402a8101b195152d6ef711.tar.gz |
When checking the value of the "isolation" key, don't assume it is NUL terminated.
Diffstat (limited to 'src/config/config.c')
-rw-r--r-- | src/config/config.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/config/config.c b/src/config/config.c index 1c49c90d0de..6a5005cde08 100644 --- a/src/config/config.c +++ b/src/config/config.c @@ -668,3 +668,28 @@ __wt_config_subgets(WT_SESSION_IMPL *session, return (__wt_config_subgetraw(session, cfg, &key_item, value)); } + +/* + * __wt_config_strcmp -- + * Compare a string value with a given string. + */ +int +__wt_config_strcmp(WT_CONFIG_ITEM *cfg, const char *str) +{ + const char *cstr; + size_t i; + + for (i = 0, cstr = cfg->str; i < cfg->len; i++, cstr++, str++) { + /* This covers hitting a NULL at the end of the string. */ + if (*cstr > *str) + return (1); + if (*cstr < *str) + return (-1); + } + + /* + * All the characters are equal: if we are at the end of the string, + * we're done. + */ + return ((*str == '\0') ? 0 : -1); +} |