`payload` probably isn't null terminated. Use `printf(`%.*s`, len, str)`.