#include "jcr.h"
sql_query p_sql_query = NULL;
+sql_escape p_sql_escape = NULL;
#define FULL_LOCATION 1 /* set for file:line in Debug messages */
}
if (type == M_ABORT || type == M_ERROR_TERM) {
-#if !defined(HAVE_WIN32)
fputs(dt, stdout);
fputs(msg, stdout); /* print this here to INSURE that it is printed */
fflush(stdout);
-#endif
}
/* Now figure out where to send the message */
if (!jcr || !jcr->db) {
break;
}
- if (p_sql_query) {
- POOL_MEM cmd(PM_MESSAGE);
+ if (p_sql_query && p_sql_escape) {
+ POOLMEM *cmd = get_pool_memory(PM_MESSAGE);
+ POOLMEM *esc_msg = get_pool_memory(PM_MESSAGE);
+
+ int len = strlen(msg) + 1;
+ esc_msg = check_pool_memory_size(esc_msg, len*2+1);
+ p_sql_escape(esc_msg, msg, len);
+
bstrftimes(dt, sizeof(dt), mtime);
Mmsg(cmd, "INSERT INTO Log (JobId, Time, LogText) VALUES (%s,'%s','%s')",
- edit_int64(jcr->JobId, ed1), dt, msg);
- p_sql_query(jcr, cmd.c_str());
+ edit_int64(jcr->JobId, ed1), dt, esc_msg);
+ p_sql_query(jcr, cmd);
+
+ free_pool_memory(cmd);
+ free_pool_memory(esc_msg);
}
break;
case MD_CONSOLE:
if (type == M_ABORT){
char *p = 0;
+ printf("Bacula forced SEG FAULT to obtain traceback.\n");
+ syslog(LOG_DAEMON|LOG_ERR, "Bacula forced SEG FAULT to obtain traceback.\n");
p[0] = 0; /* generate segmentation violation */
}
if (type == M_ERROR_TERM) {