Max msg

This patch set adds an upper limit (PW_MAX_MSG_SIZE) to the msg parameter passed in the library functions. The library functions are then modified to prevent overflows over that size. Moreover it allows for the msg parameter to be NULL (and then ignored).