This appears to be a FP. Work around it to allow for using this warning
as an error.
Limit scheme lenght to < 256 as well.
app-layer-smtp.c: In function 'SMTPConfigure':
app-layer-smtp.c:371:69: warning: 'snprintf' output may be truncated before the last format character [-Wformat-truncation=]
371 | int r = snprintf(new_val, scheme_len + 1, "%s://", scheme->val);
| ^
app-layer-smtp.c:371:29: note: 'snprintf' output 4 or more bytes (assuming 5) into a destination of size 4
371 | int r = snprintf(new_val, scheme_len + 1, "%s://", scheme->val);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ticket: #7905.
detect-engine-analyzer.c: In function ‘SetupEngineAnalysis’:
detect-engine-analyzer.c:493:60: error: ‘%s’ directive output may be truncated writing up to 63 bytes into a region of size 3 [-Werror=format-truncation=]
493 | snprintf(ea->file_prefix, cfg_prefix_len + 1 + 1, "%s.", de_ctx->config_prefix);
| ^~
detect-engine-analyzer.c:493:9: note: ‘snprintf’ output between 2 and 65 bytes into a destination of size 3
493 | snprintf(ea->file_prefix, cfg_prefix_len + 1 + 1, "%s.", de_ctx->config_prefix);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ticket: #7905.
This appears to be a FP. Work around it to allow for using this warning
as an error.
detect-engine-address.c: In function ‘DetectAddressParseInternal’:
detect-engine-address.c:851:35: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=]
851 | "[%s]", rule_var_address);
| ^
detect-engine-address.c:850:21: note: ‘snprintf’ output 3 or more bytes (assuming 4) into a destination of size 3
850 | snprintf(temp_rule_var_address, str_size,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
851 | "[%s]", rule_var_address);
| ~~~~~~~~~~~~~~~~~~~~~~~~~
detect-engine-address.c:919:34: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=]
919 | "[%s]", rule_var_address);
| ^
detect-engine-address.c:918:21: note: ‘snprintf’ output 3 or more bytes (assuming 4) into a destination of size 3
918 | snprintf(temp_rule_var_address, strlen(rule_var_address) + 3,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
919 | "[%s]", rule_var_address);
| ~~~~~~~~~~~~~~~~~~~~~~~~~
Ticket: #7905.
detect-dataset.c: In function ‘SetupLoadPath’:
detect-dataset.c:391:9: error: ‘%s’ directive output may be truncated writing likely 1 or more bytes into a region of size between 0 and 4095 [-Werror=format-truncation=]
391 | if (snprintf(path, sizeof(path), "%s/%s", dir, load) >= (int)sizeof(path)) // TODO windows path
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
detect-dataset.c:391:9: note: assuming directive output of 1 byte
detect-dataset.c:391:9: note: ‘snprintf’ output 2 or more bytes (assuming 4098) into a destination of size 4096
Ticket: #7905.
detect-datarep.c: In function ‘SetupLoadPath’:
detect-datarep.c:262:9: error: ‘%s’ directive output may be truncated writing likely 1 or more bytes into a region of size between 0 and 4095 [-Werror=format-truncation=]
262 | if (snprintf(path, sizeof(path), "%s/%s", dir, load) >= (int)sizeof(path)) // TODO windows path
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
detect-datarep.c:262:9: note: assuming directive output of 1 byte
detect-datarep.c:262:9: note: ‘snprintf’ output 2 or more bytes (assuming 4098) into a destination of size 4096
cc1: all warnings being treated as errors
Ticket: #7905.
util-pidfile.c: In function ‘SCPidfileCreate’:
util-pidfile.c:49:18: error: ‘%lu’ directive output may be truncated writing between 1 and 20 bytes into a region of size 16 [-Werror=format-truncation=]
49 | size_t len = snprintf(val, sizeof(val), "%"PRIuMAX"\n", (uintmax_t)getpid());
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
util-pidfile.c:49:18: note: using the range [0, 18446744073709551615] for directive argument
util-pidfile.c:49:18: note: ‘snprintf’ output between 3 and 22 bytes into a destination of size 16
49 | size_t len = snprintf(val, sizeof(val), "%"PRIuMAX"\n", (uintmax_t)getpid());
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
Ticket: #7905.
Fix crashes in Lua when calling tx:response_line(), tx:request_line(),
tx:request_uri_raw(), or tx:request_host() on incomplete or malformed
HTTP transactions.
These functions return bstr pointers which may be NULL. Add NULL
checks before calling bstr_ptr() and bstr_len() to avoid segfaults.
Ticket: #7829