
To verify this, I malloc'd 32 bytes right after the stack was initialized, set all to 0, and then checked the content each time the app callback function is called by the stack. Sure enough, 7 bytes are being overwritten by the stack code (looks like the last 7 bytes of received data when the packet size is maxed out).
I added some code to the zg_process_isr() function in g2100.c to monitor how much data was being written into the uip buffer in the ZG_INTR_ST_RD_CTRL_REG state where it reads the contents of a received data packet and stores it in the uip buffer. Sure enough, with the default UIP_CONF_BUFFER_SIZE of 400 bytes, I was seeing rx_byte_cnt values of 416! With the extra byte for the command at element 0, that means 417 bytes were being written in the 400 byte uIP buffer. When this occurred, the received data at the app level was reported to be 346 bytes (the correct maximum payload for a 400 byte buffer).
This is a pretty serious bug, so I hope you guys will be able to fix it soon (do let me know if I can be of further assistance). In the meantime, I'll probably keep my malloc(32) as a safety buffer between the stack and my data.
