msg->length is too small by 2 which truncates the message. (removing the - 2 here fixes it but is obviously not the proper fix.)