Fix some memory allocation blunders.

In addmsg: Use sizeof(log_t) rather than sizeof(data_t) as memory for a
pointer to data_t is being allocated.

In getlog, initialize len to 0 to prevent from allocating random number
of bytes.

In the 2nd while loop, move the cursor to the next node to prevent from
infinite loop.