mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-01 11:32:48 -05:00
Utility function strbuf_dup.
If you already have a string (of potentially-binary data) in the form of a ptrlen reference to somewhere else, and you want to keep a copy somewhere, it's useful to copy it into a strbuf. But it takes a couple of lines of faff to do that, and it's nicer to wrap that up into a tiny helper function. This commit adds that helper function strbuf_dup, and its non-movable sibling strbuf_dup_nm for secret data. Also, gone through the existing code and found a bunch of cases where this makes things less verbose.
This commit is contained in:
@ -348,10 +348,8 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
|
||||
s->agent_keys_len = nkeys;
|
||||
s->agent_keys = snewn(s->agent_keys_len, agent_key);
|
||||
for (size_t i = 0; i < nkeys; i++) {
|
||||
s->agent_keys[i].blob = strbuf_new();
|
||||
put_datapl(s->agent_keys[i].blob, get_string(s->asrc));
|
||||
s->agent_keys[i].comment = strbuf_new();
|
||||
put_datapl(s->agent_keys[i].comment, get_string(s->asrc));
|
||||
s->agent_keys[i].blob = strbuf_dup(get_string(s->asrc));
|
||||
s->agent_keys[i].comment = strbuf_dup(get_string(s->asrc));
|
||||
|
||||
/* Also, extract the algorithm string from the start
|
||||
* of the public-key blob. */
|
||||
|
Reference in New Issue
Block a user