Skip to content

Commit d1bcfa8

Browse files
authored
out_stackdriver: Make out_stackdriver compilable with MSVC (#2453)
MSVC does not support variable length arrays. For this reason, this line raises a syntax error while compilation. error C2133: 'extract_latency': unknown size Avoid that error by using a fixed buffer size. Note: According to the spec, the max value of latency/Duration is "315576000000.999999999s". So a 64 bytes buffer should be enough, even if there are some white spaces prefixed. Signed-off-by: Fujimoto Seiji <[email protected]>
1 parent 74e1586 commit d1bcfa8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

plugins/out_stackdriver/stackdriver_http_request.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,16 +185,23 @@ void add_http_request_field(struct http_request_field *http_request,
185185
/* latency should be in the format:
186186
* whitespace (opt.) + integer + point & decimal (opt.)
187187
* + whitespace (opt.) + "s" + whitespace (opt.)
188+
*
189+
* latency is Duration, so the maximum value is "315576000000.999999999s".
190+
* (23 characters in length)
188191
*/
189192
static void validate_latency(msgpack_object_str latency_in_payload,
190193
struct http_request_field *http_request) {
191194
flb_sds_t pattern = flb_sds_create("^\\s*\\d+(.\\d+)?\\s*s\\s*$");
192-
char extract_latency[latency_in_payload.size];
195+
char extract_latency[32];
193196
struct flb_regex *regex;
194197

195198
int status = 0;
196199
int i = 0, j = 0;
197200

201+
if (latency_in_payload.size > sizeof(extract_latency)) {
202+
return;
203+
}
204+
198205
regex = flb_regex_create(pattern);
199206
status = flb_regex_match(regex, latency_in_payload.ptr, latency_in_payload.size);
200207
flb_regex_destroy(regex);

0 commit comments

Comments
 (0)