strcpy() can't work here because the data doesn't have to be NULL-terminated. So let's use memcpy. Fix memleak of plain_str.