*/
p = buffer;
while ((q = strchr(p, ';'))) {
+ uint32_t statement_len;
+
if ((q[1] != '\n') && (q[1] != '\0')) {
p = q + 1;
statement_cnt++;
continue;
}
+#ifndef NDEBUG
+ if ((q - p) > (1 << 20)) {
+ sql_print_error(db, status, "Failed preparing statement %i: too long!", statement_cnt);
+ talloc_free(buffer);
+ return -1;
+ }
+#endif
+
+ statement_len = q - p;
+
#ifdef HAVE_SQLITE3_PREPARE_V2
- status = sqlite3_prepare_v2(db, p, q - p, &statement, &z_tail);
+ status = sqlite3_prepare_v2(db, p, statement_len, &statement, &z_tail);
#else
- status = sqlite3_prepare(db, p, q - p, &statement, &z_tail);
+ status = sqlite3_prepare(db, p, statement_len, &statement, &z_tail);
#endif
if (sql_check_error(db, status) != RLM_SQL_OK) {