[PATCH 12/13] gdb/remote: remove uses of sprintf
Simon Marchi
simon.marchi@efficios.com
Mon Aug 17 17:34:21 GMT 2026
On 8/17/26 12:51 PM, Andrew Burgess wrote:
>> @@ -11532,35 +11533,42 @@ remote_add_target_side_condition (struct gdbarch *gdbarch,
>> /* Send conditions to the target. */
>> for (agent_expr *aexpr : bp_tgt->conditions)
>> {
>> - xsnprintf (buf, buf_end - buf, "X%x,", (int) aexpr->buf.size ());
>> - buf += strlen (buf);
>> + buf += xsnprintf (buf, buf_end - buf, "X%x,", (int) aexpr->buf.size ());
>> +
>> for (int i = 0; i < aexpr->buf.size (); ++i)
>> buf = pack_hex_byte (buf, aexpr->buf[i]);
>> +
>
> I wonder if we should add an assert here either inside, or just after,
> the loop, to check that we've not blown past BUF_END? Unless I'm
> misunderstanding this, these PACK_HEX_BYTE calls could overrun the
> buffer, right?
I noted in the commit message that I didn't do it, because I wanted to
focus just on the *printf calls, but I can always do it as a follow-up.
Simon
More information about the Binutils
mailing list