Skip to content

Commit e09a07a

Browse files
committed
CDRIVER-1953 Escape double quotes in MONGOC_USER_SET_LDFLAGS/CC/CFLAGS
1 parent bbd3111 commit e09a07a

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

src/mongoc/mongoc-handshake-compiler-private.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717
#define MONGOC_HANDSHAKE_COMPILER_PRIVATE_H
1818

1919
#include "mongoc-config.h"
20-
21-
/* Helper macros for stringifying things */
22-
#define MONGOC_STR(s) #s
23-
#define MONGOC_EVALUATE_STR(s) MONGOC_STR(s)
20+
#include "mongoc-util-private.h"
2421

2522
/*
2623
* Thanks to:
@@ -55,7 +52,7 @@
5552
/* Portable C Compiler. Version may not be available */
5653
#define MONGOC_COMPILER "PCC"
5754
#else
58-
#define MONGOC_COMPILER MONGOC_CC
55+
#define MONGOC_COMPILER MONGOC_EVALUATE_STR (MONGOC_CC)
5956
/* Not defining COMPILER_VERSION. We'll fall back to values set at
6057
* configure-time */
6158
#endif

src/mongoc/mongoc-handshake.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,14 @@ _set_platform_string (mongoc_handshake_t *handshake)
300300
bson_string_append_printf (str, " %s", MONGOC_COMPILER_VERSION);
301301
#endif
302302

303-
if (strlen (MONGOC_USER_SET_CFLAGS) > 0) {
304-
bson_string_append_printf (str, " CFLAGS=%s", MONGOC_USER_SET_CFLAGS);
303+
if (strlen (MONGOC_EVALUATE_STR (MONGOC_USER_SET_CFLAGS)) > 0) {
304+
bson_string_append_printf (
305+
str, " CFLAGS=%s", MONGOC_EVALUATE_STR (MONGOC_USER_SET_CFLAGS));
305306
}
306307

307-
if (strlen (MONGOC_USER_SET_LDFLAGS) > 0) {
308-
bson_string_append_printf (str, " LDFLAGS=%s", MONGOC_USER_SET_LDFLAGS);
308+
if (strlen (MONGOC_EVALUATE_STR (MONGOC_USER_SET_LDFLAGS)) > 0) {
309+
bson_string_append_printf (
310+
str, " LDFLAGS=%s", MONGOC_EVALUATE_STR (MONGOC_USER_SET_LDFLAGS));
309311
}
310312

311313
handshake->platform = bson_string_free (str, false);

src/mongoc/mongoc-util-private.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@
4949
# define MONGOC_RAND_R rand_r
5050
#endif
5151

52+
/* Helper macros for stringifying things */
53+
#define MONGOC_STR(s) #s
54+
#define MONGOC_EVALUATE_STR(s) MONGOC_STR (s)
55+
5256
BSON_BEGIN_DECLS
5357

5458

0 commit comments

Comments
 (0)