From: František Dvořák Date: Thu, 13 Jan 2011 14:35:14 +0000 (+0000) Subject: Fix segfault when logging messages > 1024 characters: X-Git-Tag: merge_21_head_round2_src~4 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=2703c38e79c3b5e9cfe75cd24bddf7c143ed695c;p=jra1mw.git Fix segfault when logging messages > 1024 characters: - problem in log4c, workarounded in configuration (needed any non-zero buffer) - new test added --- diff --git a/org.glite.lbjp-common.log/Makefile b/org.glite.lbjp-common.log/Makefile index 80846d0..26b420d 100644 --- a/org.glite.lbjp-common.log/Makefile +++ b/org.glite.lbjp-common.log/Makefile @@ -16,7 +16,7 @@ log4c_prefix=/usr version=${module.version} CC=gcc -VPATH=${top_srcdir}/interface:${top_srcdir}/src +VPATH=${top_srcdir}/interface:${top_srcdir}/src:${top_srcdir}/tests LOG4C_CFLAGS:=-I${log4c_prefix}/include LOG4C_LIBS:=-L${log4c_prefix}/${libdir} -L${log4c_prefix}/lib -llog4c @@ -78,10 +78,14 @@ clean: rm -rvf *.o *.lo .libs lib* rm -rvf log.xml project/ rpmbuild/ RPMS/ tgz/ debian/ -check: +check: test + LOG4C_RCPATH=${top_srcdir}/tests ./test ${LTLIB}: ${LOBJS} ${LINK} ${version_info} -o $@ $+ ${LOG4C_LIBS} +test: test.o + ${LINK} -o $@ $+ ${LTLIB} ${LOG4C_LIBS} + %.o %.lo: %.c ${COMPILE} -c $< diff --git a/org.glite.lbjp-common.log/config/log4crc b/org.glite.lbjp-common.log/config/log4crc index bb473b5..f567e20 100644 --- a/org.glite.lbjp-common.log/config/log4crc +++ b/org.glite.lbjp-common.log/config/log4crc @@ -4,7 +4,7 @@ - 0 + 512 0 diff --git a/org.glite.lbjp-common.log/config/log4crc.debugging b/org.glite.lbjp-common.log/config/log4crc.debugging index 7e21543..3966378 100644 --- a/org.glite.lbjp-common.log/config/log4crc.debugging +++ b/org.glite.lbjp-common.log/config/log4crc.debugging @@ -4,7 +4,7 @@ - 0 + 512 0 diff --git a/org.glite.lbjp-common.log/tests/log4crc b/org.glite.lbjp-common.log/tests/log4crc new file mode 100644 index 0000000..575056f --- /dev/null +++ b/org.glite.lbjp-common.log/tests/log4crc @@ -0,0 +1,17 @@ + + + + + + 512 + + 0 + + + + + + + + + diff --git a/org.glite.lbjp-common.log/tests/test.c b/org.glite.lbjp-common.log/tests/test.c new file mode 100644 index 0000000..524cb4e --- /dev/null +++ b/org.glite.lbjp-common.log/tests/test.c @@ -0,0 +1,32 @@ +#include +#include + +#include "log.h" + +int main() { + char *line = NULL; + size_t i, n; + const char *testcat = "miaow"; + + n = 10000; + line = malloc(n); + for (i = 0; i < n; i++) line[i] = (i % 64) ? 'A' : '\n'; + line[n - 3] = '#'; + line[n - 2] = '\n'; + line[n - 1] = '\0'; + + + if (glite_common_log_init()) { + fprintf(stderr,"glite_common_log_init() failed, exiting."); + return 2; + } + + glite_common_log(testcat, LOG_PRIORITY_ERROR, "%s", line); + glite_common_log(testcat, LOG_PRIORITY_DEBUG, "%s", line); + printf("%s\n", line); + + glite_common_log_fini(); + + free(line); + return 0; +}