mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 15:17:01 +02:00
MINOR: chunks: always initialize the output chunk in get_trash_chunk()
The get_trash_chunk() function is convenient and is sometimes used even
to get a temporary string. While the chunk is initialized, the string
may contain some random garbage that some code might retrieve if it uses
chunk->str directly without checking ->len. This is what happened in checks
after commit 25e2ab5
(MEDIUM: checks: centralize error reporting). It's not
easy to guess it at first so better pre-initialize the string with a zero.
This commit is contained in:
parent
89efaed6b6
commit
031ad23c47
@ -33,7 +33,9 @@ static char *trash_buf2;
|
||||
* type of conversion. Two chunks and their respective buffers are alternatively
|
||||
* returned so that it is always possible to iterate data transformations without
|
||||
* losing the data being transformed. The blocks are initialized to the size of
|
||||
* a standard buffer, so they should be enough for everything.
|
||||
* a standard buffer, so they should be enough for everything. For convenience,
|
||||
* a zero is always emitted at the beginning of the string so that it may be
|
||||
* used as an empty string as well.
|
||||
*/
|
||||
struct chunk *get_trash_chunk(void)
|
||||
{
|
||||
@ -47,6 +49,7 @@ struct chunk *get_trash_chunk(void)
|
||||
trash_chunk = &trash_chunk1;
|
||||
trash_buf = trash_buf1;
|
||||
}
|
||||
*trash_buf = 0;
|
||||
chunk_init(trash_chunk, trash_buf, trash_size);
|
||||
return trash_chunk;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user