prelude-lml/master: Fix possible log truncation
[email protected] Mon, 8 Feb 2010 11:24:48 +0100 (CET)
| Newsgroups | gmane.comp.security.ids.prelude.cvs |
|---|---|
| Message-ID | <[email protected]> |
commit f49262280bac85d99022084a80cd2df64d6cb2c5 Author: Yoann Vandoorselaere <[email protected]> Date: Fri Feb 5 18:25:28 2010 +0100 Fix possible log truncation Do not use strdup() for copying the dispatched log, since it might carry multiple nul terminator, and the copy might thus stop before the true end of the string. Rather, use malloc() + memcpy() combination. This fixes a regression of LML 1.0.0rc1 ======================================== src/log-source.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) ======================================== diff --git a/src/log-source.c b/src/log-source.c index 687d07a..dc8cf84 100644 --- a/src/log-source.c +++ b/src/log-source.c @@ -128,11 +128,16 @@ static lml_log_format_t *lml_log_format_ref(lml_log_format_t *lf) static inline int _fallback_preprocess_input(lml_log_source_t *source, const char *in, size_t inlen, char **out, size_t *outlen) { - *out = strdup(in); + if ( inlen + 1 < inlen ) + return -1; + + *out = malloc(inlen + 1); if ( ! *out ) return -1; *outlen = inlen; + memcpy(*out, in, inlen + 1); + return 0; } _______________________________________________ Prelude-cvslog site list [email protected] http://lists.prelude-technologies.com/mailman/listinfo/prelude-cvslog