AnsweredAssumed Answered

_lwmsgq_init ( ) API implies size of int instead of byte

Question asked by barco hes on Dec 13, 2010
Latest reply on Jan 27, 2011 by Juraj Vanco

If you create a block of data suitable for _lwmsgq_init() and your message size is less than the size of an integer you will get memory corruption.  In the case of creating a message size of 1 byte and a message count of 1, the internals of the lwmsgq_xxxx() functions will corrupt memory following the preallocoted user buffer passed to _lwmsgq_init(). This happens since the _lwmsgq_xxx() functions operate with int pointers with the size passed into it's initialization.


This is not exactly wrong if you were to document that this were the case, but it is more common to think of sizes as bytes and not integers unless explicitly documented. In this case there is no such documentation in the MQXRM.pdf. This also limits messages for the queue to be a minimum of 4 bytes.


M8R-jw5952 at mailinator dot com