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 (src && len) {
|
||||||
|
if (++len > size)
|
||||||
|
len = size;
|
||||||
if (node->options & LOG_OPT_ESC) {
|
if (node->options & LOG_OPT_ESC) {
|
||||||
struct chunk chunk;
|
|
||||||
char *ret;
|
char *ret;
|
||||||
|
|
||||||
chunk_initlen(&chunk, (char *)src, 0, len);
|
ret = escape_string(dst, dst + len, '\\', rfc5424_escape_map, src);
|
||||||
ret = escape_chunk(dst, dst + size, '\\', rfc5424_escape_map, &chunk);
|
|
||||||
if (ret == NULL || *ret != '\0')
|
if (ret == NULL || *ret != '\0')
|
||||||
return NULL;
|
return NULL;
|
||||||
len = ret - dst;
|
len = ret - dst;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (++len > size)
|
|
||||||
len = size;
|
|
||||||
len = strlcpy2(dst, src, len);
|
len = strlcpy2(dst, src, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user