Skip to content

Commit 9f9f48b

Browse files
committed
Replace snprintf with bson_snprintf
1 parent 5b0dbb3 commit 9f9f48b

File tree

2 files changed

+18
-22
lines changed

2 files changed

+18
-22
lines changed

src/libmongoc/tests/json-test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1930,7 +1930,7 @@ _install_json_test_suite_with_check (TestSuite *suite,
19301930
char joined[PATH_MAX];
19311931
char resolved[PATH_MAX];
19321932

1933-
snprintf (joined, PATH_MAX, "%s/%s", base, subdir);
1933+
bson_snprintf (joined, PATH_MAX, "%s/%s", base, subdir);
19341934
ASSERT (realpath (joined, resolved));
19351935

19361936
if (suite->ctest_run) {

src/libmongoc/tests/test-mongoc-uri.c

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
#include "test-libmongoc.h"
1212
#include "test-conveniences.h"
1313

14-
#ifdef _WIN32
15-
#define snprintf _snprintf
16-
#endif
17-
1814
static void
1915
test_mongoc_uri_new (void)
2016
{
@@ -1579,7 +1575,7 @@ test_mongoc_uri_tls_ssl (const char *tls,
15791575
mongoc_uri_t *uri;
15801576
bson_error_t err;
15811577

1582-
snprintf (url_buffer,
1578+
bson_snprintf (url_buffer,
15831579
sizeof (url_buffer),
15841580
"mongodb://CN=client,OU=kerneluser,O=10Gen,L=New York City,"
15851581
"ST=New York,[email protected]/?"
@@ -1617,7 +1613,7 @@ test_mongoc_uri_tls_ssl (const char *tls,
16171613
mongoc_uri_destroy (uri);
16181614

16191615

1620-
snprintf (url_buffer,
1616+
bson_snprintf (url_buffer,
16211617
sizeof (url_buffer),
16221618
"mongodb://localhost/?%s=true&%s=key.pem&%s=ca.pem",
16231619
tls,
@@ -1650,7 +1646,7 @@ test_mongoc_uri_tls_ssl (const char *tls,
16501646
mongoc_uri_destroy (uri);
16511647

16521648

1653-
snprintf (
1649+
bson_snprintf (
16541650
url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=true", tls);
16551651
uri = mongoc_uri_new (url_buffer);
16561652

@@ -1670,7 +1666,7 @@ test_mongoc_uri_tls_ssl (const char *tls,
16701666
mongoc_uri_destroy (uri);
16711667

16721668

1673-
snprintf (url_buffer,
1669+
bson_snprintf (url_buffer,
16741670
sizeof (url_buffer),
16751671
"mongodb://localhost/?%s=true&%s=pa$$word!&%s=encrypted.pem",
16761672
tls,
@@ -1703,7 +1699,7 @@ test_mongoc_uri_tls_ssl (const char *tls,
17031699
mongoc_uri_destroy (uri);
17041700

17051701

1706-
snprintf (url_buffer,
1702+
bson_snprintf (url_buffer,
17071703
sizeof (url_buffer),
17081704
"mongodb://localhost/?%s=true&%s=true",
17091705
tls,
@@ -1730,7 +1726,7 @@ test_mongoc_uri_tls_ssl (const char *tls,
17301726
mongoc_uri_destroy (uri);
17311727

17321728

1733-
snprintf (url_buffer,
1729+
bson_snprintf (url_buffer,
17341730
sizeof (url_buffer),
17351731
"mongodb://localhost/?%s=foo.pem",
17361732
tlsCertificateKeyFile);
@@ -1740,7 +1736,7 @@ test_mongoc_uri_tls_ssl (const char *tls,
17401736
mongoc_uri_destroy (uri);
17411737

17421738

1743-
snprintf (url_buffer,
1739+
bson_snprintf (url_buffer,
17441740
sizeof (url_buffer),
17451741
"mongodb://localhost/?%s=foo.pem",
17461742
tlsCAFile);
@@ -1750,7 +1746,7 @@ test_mongoc_uri_tls_ssl (const char *tls,
17501746
mongoc_uri_destroy (uri);
17511747

17521748

1753-
snprintf (url_buffer,
1749+
bson_snprintf (url_buffer,
17541750
sizeof (url_buffer),
17551751
"mongodb://localhost/?%s=true",
17561752
tlsAllowInvalidCertificates);
@@ -1764,7 +1760,7 @@ test_mongoc_uri_tls_ssl (const char *tls,
17641760
mongoc_uri_destroy (uri);
17651761

17661762

1767-
snprintf (url_buffer,
1763+
bson_snprintf (url_buffer,
17681764
sizeof (url_buffer),
17691765
"mongodb://localhost/?%s=true",
17701766
tlsAllowInvalidHostnames);
@@ -1778,7 +1774,7 @@ test_mongoc_uri_tls_ssl (const char *tls,
17781774
mongoc_uri_destroy (uri);
17791775

17801776

1781-
snprintf (url_buffer,
1777+
bson_snprintf (url_buffer,
17821778
sizeof (url_buffer),
17831779
"mongodb://localhost/?%s=false&%s=foo.pem",
17841780
tls,
@@ -1789,7 +1785,7 @@ test_mongoc_uri_tls_ssl (const char *tls,
17891785
mongoc_uri_destroy (uri);
17901786

17911787

1792-
snprintf (url_buffer,
1788+
bson_snprintf (url_buffer,
17931789
sizeof (url_buffer),
17941790
"mongodb://localhost/?%s=false&%s=foo.pem",
17951791
tls,
@@ -1800,7 +1796,7 @@ test_mongoc_uri_tls_ssl (const char *tls,
18001796
mongoc_uri_destroy (uri);
18011797

18021798

1803-
snprintf (url_buffer,
1799+
bson_snprintf (url_buffer,
18041800
sizeof (url_buffer),
18051801
"mongodb://localhost/?%s=false&%s=true",
18061802
tls,
@@ -1815,7 +1811,7 @@ test_mongoc_uri_tls_ssl (const char *tls,
18151811
mongoc_uri_destroy (uri);
18161812

18171813

1818-
snprintf (url_buffer,
1814+
bson_snprintf (url_buffer,
18191815
sizeof (url_buffer),
18201816
"mongodb://localhost/?%s=false&%s=false",
18211817
tls,
@@ -1837,7 +1833,7 @@ test_mongoc_uri_tls_ssl (const char *tls,
18371833

18381834
/* Mixing options okay so long as they match */
18391835
capture_logs (true);
1840-
snprintf (url_buffer,
1836+
bson_snprintf (url_buffer,
18411837
sizeof (url_buffer),
18421838
"mongodb://localhost/?%s=true&%s=true",
18431839
tls,
@@ -1849,7 +1845,7 @@ test_mongoc_uri_tls_ssl (const char *tls,
18491845

18501846
/* Same option with different values okay, latter overrides */
18511847
capture_logs (true);
1852-
snprintf (url_buffer,
1848+
bson_snprintf (url_buffer,
18531849
sizeof (url_buffer),
18541850
"mongodb://localhost/?%s=true&%s=false",
18551851
tls,
@@ -1869,7 +1865,7 @@ test_mongoc_uri_tls_ssl (const char *tls,
18691865

18701866
/* Mixing options not okay if values differ */
18711867
capture_logs (false);
1872-
snprintf (url_buffer,
1868+
bson_snprintf (url_buffer,
18731869
sizeof (url_buffer),
18741870
"mongodb://localhost/?%s=true&%s=false",
18751871
tls,
@@ -1892,7 +1888,7 @@ test_mongoc_uri_tls_ssl (const char *tls,
18921888

18931889
/* No conflict appears with implicit tls=true via SRV */
18941890
capture_logs (false);
1895-
snprintf (url_buffer,
1891+
bson_snprintf (url_buffer,
18961892
sizeof (url_buffer),
18971893
"mongodb+srv://a.b.c/?%s=foo.pem",
18981894
tlsCAFile);

0 commit comments

Comments
 (0)