case etSQLESCAPE2:
case etSQLESCAPE4:
case etSQLESCAPE3:{
- int i, j, n, ch, isnull;
- int needQuote;
+ size_t i, j, n, ch;
+ int needQuote, isnull;
char *escarg = va_arg(ap, char *);
isnull = escarg == 0;
if (isnull)
#include <openssl/ssl.h>
#endif
+#define ENABLE_SNPRINTFV_TESTS 0 /* Do not turn on for CI as this requires a lot of RAM */
+
FST_CORE_BEGIN("./conf")
{
FST_SUITE_BEGIN(switch_core)
}
FST_TEARDOWN_END()
+#if ENABLE_SNPRINTFV_TESTS
+ FST_TEST_BEGIN(test_snprintfv_1)
+ {
+ size_t src_buf_size = 0x100000001;
+ char* src = calloc(1, src_buf_size);
+
+ if (!src) {
+ printf("bad allocation\n");
+
+ return -1;
+ }
+
+ src[0] = '\xc0';
+ memset(src + 1, '\x80', 0xffffffff);
+
+ char dst[256];
+ switch_snprintfv(dst, 256, "'%!q'", src);
+ free(src);
+ }
+ FST_TEST_END()
+
+ FST_TEST_BEGIN(test_snprintfv_2)
+ {
+#define STR_LEN ((0x100000001 - 3) / 2)
+
+ char* src = calloc(1, STR_LEN + 1); /* Account for NULL byte. */
+
+ if (!src) { return -1; }
+
+ memset(src, 'a', STR_LEN);
+
+ char* dst = calloc(1, STR_LEN + 3); /* Account for extra quotes and NULL byte */
+ if (!dst) { return -1; }
+
+ switch_snprintfv(dst, 2 * STR_LEN + 3, "'%q'", src);
+
+ free(src);
+ free(dst);
+ }
+ FST_TEST_END()
+#endif
+
FST_TEST_BEGIN(test_switch_event_add_header_leak)
{
switch_event_t* event;