mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-12 00:16:58 +00:00
BUG/MEDIUM: log: use function "escape_string" instead of "escape_chunk"
In function lf_text_len(), we used escape_chunk() to escape special characters. There could be a problem if len is greater than the real src string length (zero-terminated), eg. when calling lf_text_len() from lf_text().
This commit is contained in:
parent
1a5d06032b
commit
db1b6f9ecb
@ -830,19 +830,17 @@ char *lf_text_len(char *dst, const char *src, size_t len, size_t size, struct lo
|
||||
}
|
||||
|
||||
if (src && len) {
|
||||
if (++len > size)
|
||||
len = size;
|
||||
if (node->options & LOG_OPT_ESC) {
|
||||
struct chunk chunk;
|
||||
char *ret;
|
||||
|
||||
chunk_initlen(&chunk, (char *)src, 0, len);
|
||||
ret = escape_chunk(dst, dst + size, '\\', rfc5424_escape_map, &chunk);
|
||||
ret = escape_string(dst, dst + len, '\\', rfc5424_escape_map, src);
|
||||
if (ret == NULL || *ret != '\0')
|
||||
return NULL;
|
||||
len = ret - dst;
|
||||
}
|
||||
else {
|
||||
if (++len > size)
|
||||
len = size;
|
||||
len = strlcpy2(dst, src, len);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user