Finding the index of a symbol in unsigned char and extracting contents?

Since callback() takes both a pointer an a length I'm guessing the contents of 'payload' is not null-terminated.

Try using strncpy() with the supplied length. You may have to explicitly add the terminator.