Does chunk.data() return a char*? If so, then this isn't quite right. You should say string(chunk.data(data_length), data_length)). Otherwise the string constructor looks for a null byte as the terminator, but a GFS file could legit have null bytes in it. By using the string constructor that takes a length you inhibit the strlen so you can build a std::string with null bytes.