Suspicious code

Steve Boyd sboydlns at gmail.com
Mon Dec 5 15:14:08 UTC 2011


When building with Visual Studio I got a warning in zeagle_n2ition3.c.  
The following code looks a bit suspicious to me.

static device_status_t
zeagle_n2ition3_init (zeagle_n2ition3_device_t *device)
{
     unsigned char answer[6 + 13] = {0};
     unsigned char command[6] = {0x02, 0x01, 0x00, 0x41, 0xBF, 0x03};
     command[11] = ~checksum_add_uint8 (command + 3, 8, 0x00) + 1;

     return zeagle_n2ition3_packet (device, command, sizeof (command), 
answer, sizeof (answer));
}

You are setting command[11] to a value when there are only 6 elements in 
command.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://libdivecomputer.org/pipermail/devel/attachments/20111205/701a31ff/attachment.html>


More information about the Devel mailing list