diff options
author | Kevin McCarthy <kevin@8t8.us> | 2020-05-25 12:23:02 -0700 |
---|---|---|
committer | Kevin McCarthy <kevin@8t8.us> | 2020-05-25 12:42:14 -0700 |
commit | 5761113a2bd4adc58c6ae8e656680fa8a513d709 (patch) | |
tree | 64bb2b25ac0d4c01492ffd1deb47cbf083a8d8ab /init.c | |
parent | d8e518db4f83f7fed8087d94a36cb5615442b10e (diff) |
Fix buffer pool buffer truncation with my_hdr and score commands.
The buffer pool is now used for command invocation, but unfortunately
a couple cases of mutt_buffer_init() were hidden in the my_hdr and
score command processors.
This would result in a shortened buffer being returned to the pool and
used later for something like the prompt - which expects LONG_STRING
everywhere.
Fix up the two places to instead copy the string over. They don't
need to grab a large buffer pool sized hunk of memory.
Also, fix the mutt_buffer_pool_release() to resize upwards in case
future code does this. I should have done this originally, but was
afraid it would paper over more serious issues. :-/
Thanks to Armin Wolfermann for reporting the problem.
Diffstat (limited to 'init.c')
-rw-r--r-- | init.c | 7 |
1 files changed, 2 insertions, 5 deletions
@@ -1703,9 +1703,7 @@ static int parse_my_hdr (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUF if (ascii_strncasecmp (buf->data, tmp->data, keylen) == 0) { /* replace the old value */ - FREE (&tmp->data); - tmp->data = buf->data; - mutt_buffer_init (buf); + mutt_str_replace (&tmp->data, mutt_b2s (buf)); return 0; } if (!tmp->next) @@ -1719,8 +1717,7 @@ static int parse_my_hdr (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUF tmp = mutt_new_list (); UserHeader = tmp; } - tmp->data = buf->data; - mutt_buffer_init (buf); + tmp->data = safe_strdup (mutt_b2s (buf)); return 0; } |