marcus905 / libnfc

Automatically exported from code.google.com/p/libnfc
GNU Lesser General Public License v3.0
0 stars 0 forks source link

libnfc/drivers/acr122_usb.c: Null pointer passed as an argument to a 'nonnull' parameter #235

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Bug reported by the clang static analyzer.

Description: Null pointer passed as an argument to a 'nonnull' parameter
File: libnfc/drivers/acr122_usb.c
Line: 570

I have no idea how to fix that.

A line 569 we have:
  DRIVER_DATA(pnd)->apdu_frame.apdu_header.bLen = (data ? data_len : le); // XXX This line is a bit tricky ^^: bLen is Lc when data != NULL... otherwise its Le.

so data may be NULL if we test its value using (data ? data_len : le)

Then at line 570 we have:
  memcpy(DRIVER_DATA(pnd)->apdu_frame.apdu_payload, data, data_len);

If data is NULL then crash!

Something is wrong/strange in this code.

Original issue reported on code.google.com by ludovic....@gmail.com on 2 Mar 2013 at 12:19

GoogleCodeExporter commented 9 years ago
Fixed in 70b0dffca750129c67d162231668d668dc0afb49

Original comment by yob...@gmail.com on 3 Mar 2013 at 12:06