[Qemu-devel] [PATCH RESEND 1/3] usb-ccid: make ccid_write_data_block() cope with null buffers

2017-03-22 Thread Philippe Mathieu-Daudé
static code analyzer complain: hw/usb/dev-smartcard-reader.c:816:5: warning: Null pointer passed as an argument to a 'nonnull' parameter memcpy(p->abData, data, len); ^~~~ Reported-by: Clang Static Analyzer Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Marc-

Re: [Qemu-devel] [PATCH RESEND 1/3] usb-ccid: make ccid_write_data_block() cope with null buffers

2017-04-07 Thread Philippe Mathieu-Daudé
Hi Markus, Gerd. On 03/23/2017 11:08 AM, Markus Armbruster wrote: Gerd Hoffmann writes: On Do, 2017-03-23 at 13:41 +0100, Markus Armbruster wrote: Gerd Hoffmann writes: Hi, oops, there are hard-coded calls with NULL/0. I suppose to fix clang warning, it would need to check if data !=

Re: [Qemu-devel] [PATCH RESEND 1/3] usb-ccid: make ccid_write_data_block() cope with null buffers

2017-03-22 Thread Markus Armbruster
Philippe Mathieu-Daudé writes: > static code analyzer complain: > > hw/usb/dev-smartcard-reader.c:816:5: warning: Null pointer passed as an > argument to a 'nonnull' parameter > memcpy(p->abData, data, len); > ^~~~ > > Reported-by: Clang Static Analyzer > Signed-o

Re: [Qemu-devel] [PATCH RESEND 1/3] usb-ccid: make ccid_write_data_block() cope with null buffers

2017-03-23 Thread Gerd Hoffmann
Hi, > > +if (len == 0) { > > +return; > > Correct only if messages without data always have the same meaning as no > message. Gerd? Not a ccid expert, but looking through the code it seems writing a (reply) data block with status and without payload (data = NULL and len = 0) is pe

Re: [Qemu-devel] [PATCH RESEND 1/3] usb-ccid: make ccid_write_data_block() cope with null buffers

2017-03-23 Thread Marc-André Lureau
Hi On Thu, Mar 23, 2017 at 11:44 AM Gerd Hoffmann wrote: > Hi, > > > > +if (len == 0) { > > > +return; > > > > Correct only if messages without data always have the same meaning as no > > message. Gerd? > > Not a ccid expert, but looking through the code it seems writing a > (repl

Re: [Qemu-devel] [PATCH RESEND 1/3] usb-ccid: make ccid_write_data_block() cope with null buffers

2017-03-23 Thread Gerd Hoffmann
Hi, > oops, there are hard-coded calls with NULL/0. I suppose to fix clang > warning, it would need to check if data != null for memcpy. I'd check for len > 0, and in that if branch we can also assert on data == NULL and thereby check that len and data are consistent. cheers, Gerd

Re: [Qemu-devel] [PATCH RESEND 1/3] usb-ccid: make ccid_write_data_block() cope with null buffers

2017-03-23 Thread Markus Armbruster
Gerd Hoffmann writes: > Hi, > >> oops, there are hard-coded calls with NULL/0. I suppose to fix clang >> warning, it would need to check if data != null for memcpy. > > I'd check for len > 0, and in that if branch we can also assert on data > == NULL and thereby check that len and data are con

Re: [Qemu-devel] [PATCH RESEND 1/3] usb-ccid: make ccid_write_data_block() cope with null buffers

2017-03-23 Thread Gerd Hoffmann
On Do, 2017-03-23 at 13:41 +0100, Markus Armbruster wrote: > Gerd Hoffmann writes: > > > Hi, > > > >> oops, there are hard-coded calls with NULL/0. I suppose to fix clang > >> warning, it would need to check if data != null for memcpy. > > > > I'd check for len > 0, and in that if branch we ca

Re: [Qemu-devel] [PATCH RESEND 1/3] usb-ccid: make ccid_write_data_block() cope with null buffers

2017-03-23 Thread Markus Armbruster
Gerd Hoffmann writes: > On Do, 2017-03-23 at 13:41 +0100, Markus Armbruster wrote: >> Gerd Hoffmann writes: >> >> > Hi, >> > >> >> oops, there are hard-coded calls with NULL/0. I suppose to fix clang >> >> warning, it would need to check if data != null for memcpy. >> > >> > I'd check for le