To avoid this situation, added 'backendMessage' function that will count the log message string length automatically.
extern int backendWaitLoop(int snmp_fd, http_addr_t *addr,
int use_bc, _cups_sccb_t side_cb);
+/*
+ * Used to log messages in backend.
+ * This was done to avoid a mismatch between the message string and the length of the string to write.
+ */
+#define CUPS_BACKEND_LOG_MESSAGE_SIZE 2048
+#define backendMessage(msg) {const char *s=msg; write(2, s, strnlen(s, CUPS_BACKEND_LOG_MESSAGE_SIZE));}
# ifdef __cplusplus
}
{
(void)sig; /* remove compiler warnings... */
- write(2, "DEBUG: Got SIGTERM.\n", 20);
+ backendMessage("DEBUG: Got SIGTERM.\n");
#if defined(HAVE_GSSAPI) && defined(HAVE_XPC)
if (child_pid)
* Flag that the job should be canceled...
*/
- write(2, "DEBUG: sigterm_handler: job_canceled = 1.\n", 42);
+ backendMessage("DEBUG: sigterm_handler: job_canceled = 1.\n");
job_canceled = 1;
return;
#endif /* !HAVE_SIGSET && !HAVE_SIGACTION */
if (DebugLevel)
- write(2, "DEBUG: ALARM!\n", 14);
+ backendMessage("DEBUG: ALARM!\n");
}
#include <fcntl.h>
#include <sys/wait.h>
#include <signal.h>
+#include "backend-private.h"
/*
data = ps_data;
write(1, data, strlen(data));
- write(2, "DEBUG: START\n", 13);
+ backendMessage("DEBUG: START\n");
timeout = 60.0;
while ((bytes = cupsBackChannelRead(buffer, sizeof(buffer),
timeout)) > 0)
write(2, buffer, (size_t)bytes);
timeout = 5.0;
}
- write(2, "\nDEBUG: END\n", 12);
+ backendMessage("\nDEBUG: END\n");
}
exit(0);
_exit(0);
else
{
- write(2, "DEBUG: Child crashed.\n", 22);
+ backendMessage("DEBUG: Child crashed.\n");
_exit(CUPS_BACKEND_STOP);
}
}