Skip to content

Commit

Permalink
test: Replace remaining sprintf with snprintf
Browse files Browse the repository at this point in the history
Use of `sprintf` is seen as a red flag as many of its uses are insecure.
OpenBSD warns about it while compiling, and some modern platforms, e.g.
[cloudlibc from cloudabi](https://github.com/NuxiNL/cloudlibc) don't
even provide it anymore.

Although our uses of these functions are secure, it can't hurt to
replace them anyway. There are only 3 occurences left, all in the
tests.
  • Loading branch information
laanwj authored and bitcartel committed Apr 4, 2018
1 parent 162cc42 commit 64b4790
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/test/dbwrapper_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ BOOST_AUTO_TEST_CASE(iterator_string_ordering)
CDBWrapper dbw(ph, (1 << 20), true, false);
for (int x=0x00; x<10; ++x) {
for (int y = 0; y < 10; y++) {
sprintf(buf, "%d", x);
snprintf(buf, sizeof(buf), "%d", x);
StringContentsSerializer key(buf);
for (int z = 0; z < y; z++)
key += key;
Expand All @@ -210,12 +210,12 @@ BOOST_AUTO_TEST_CASE(iterator_string_ordering)
seek_start = 0;
else
seek_start = 5;
sprintf(buf, "%d", seek_start);
snprintf(buf, sizeof(buf), "%d", seek_start);
StringContentsSerializer seek_key(buf);
it->Seek(seek_key);
for (int x=seek_start; x<10; ++x) {
for (int y = 0; y < 10; y++) {
sprintf(buf, "%d", x);
snprintf(buf, sizeof(buf), "%d", x);
string exp_key(buf);
for (int z = 0; z < y; z++)
exp_key += exp_key;
Expand Down

0 comments on commit 64b4790

Please sign in to comment.