... and ensure any potential pgm->fd.usb.max_xfer change during the
jtag3_edbg_recv_frame() call by any of the used functions won't overrun
the receive buffer.
There is no guarantee that jtag3_edbg_recv_frame()'s
rv = serial_recv(&pgm->fd, buf, pgm->fd.usb.max_xfer);
won't overrun the remaining buffer that buf points to as buf sweeps the
initial buffer within the do loop. While checks prevent buf pointing
beyond the initial generous allocation of USBDEV_MAX_XFER_3 bytes, above
call requires there be pgm->fd.usb.max_xfer more space available.
Fingers crossed pgm->fd.usb.max_xfer wont't be changed during the
jtag3_edbg_recv_frame() call by any of the used functions within.
usbhid_send() now returns an error if a different number of bytes were
reported to be written than requested. usbhid_recv() now returns an error
if more bytes were reported to be received than requested (this should
never happen, though).
This commit also improves the error messaging.
One source for errors is the use of a free'd pointer. This commit sets to
NULL free'd pointers that *may* be available to the caller. Improper use
of these free'd pointer should then result in an exception or core dump
that ought to be easier to locate than otherwise.
The developer option `-p*/s` is routinely used for canonicalisation of the
system configuration file, as are the options `-p*/si` and `-p*/s` that
are used for programmatically injecting .atdf properties into the
`avrdude.conf` file. These techniques interfere with the `modify`
operation that is only meant for last-resort changes of parts or
programmers in the per-user configuration file.