summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Bostic <keith.bostic@mongodb.com>2017-03-24 08:59:59 -0400
committerGitHub <noreply@github.com>2017-03-24 08:59:59 -0400
commit0641cc7b36a130111c19c955875862ed989a1beb (patch)
tree4a9fff406f7a3a95553a34161c6b3b3874790a47
parent1ceddd4a972bf220db9585739e9fcb283d618da4 (diff)
downloadmongo-0641cc7b36a130111c19c955875862ed989a1beb.tar.gz
WT-3136 bug fix: WiredTiger doesn't check sprintf calls for error return (#3347)
Add a style check for use of the snprintf/vsnprintf calls rather than the WiredTiger library replacements. Fix a wtperf snprintf call I missed.
-rw-r--r--bench/wtperf/wtperf.c4
-rwxr-xr-xdist/s_style8
2 files changed, 10 insertions, 2 deletions
diff --git a/bench/wtperf/wtperf.c b/bench/wtperf/wtperf.c
index 1eedaba4f32..80416cfdd5c 100644
--- a/bench/wtperf/wtperf.c
+++ b/bench/wtperf/wtperf.c
@@ -2608,8 +2608,8 @@ main(int argc, char *argv[])
append_comma = ",";
}
if (opts->in_memory) {
- pos += (size_t)snprintf(
- cc_buf + pos, req_len - pos, "%s%s",
+ testutil_check(__wt_snprintf_len_incr(
+ cc_buf + pos, req_len - pos, &pos, "%s%s",
append_comma, "in_memory=true");
append_comma = ",";
}
diff --git a/dist/s_style b/dist/s_style
index 8e755224ee2..388a481ef56 100755
--- a/dist/s_style
+++ b/dist/s_style
@@ -93,6 +93,14 @@ else
cat $t
fi
+ if ! expr "$f" : 'examples/c/*' > /dev/null &&
+ ! expr "$f" : 'ext/*' > /dev/null &&
+ ! expr "$f" : 'src/os_posix/os_snprintf.c' > /dev/null &&
+ egrep '[^a-z_]snprintf\(|[^a-z_]vsnprintf\(' $f > $t; then
+ echo "$f: snprintf call, use WiredTiger library replacements"
+ cat $t
+ fi
+
# Alignment directive before "struct".
egrep 'WT_COMPILER_TYPE_ALIGN.*struct' $f > $t
test -s $t && {