-
-
Notifications
You must be signed in to change notification settings - Fork 244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Embedded nulls not correctly read via DataSet::p_read_fixed_len #3034
Comments
To illustrate the issue, here's an example C++ program. #include <string>
#include <iostream>
int main ()
{
std::string str1, str2;
const char* str_data = "Test\0string";
const int str_data_len = 11;
/* Uses string& operator= (const char* s), truncates at first null byte */
str1 = str_data;
/* uses string& operator= (const string& str), embedded null byte is included */
str2 = std::string(str_data, str_data_len);
std::cout << "str1: " << str1 << '\n';
std::cout << "str2: " << str2 << '\n';
return 0;
} The output of this is as follows.
|
@steven-varga What are your thoughts about this? |
Ultrafeel seems to have recognized the same issue: |
The DDL resembles to an EBNF variant, and doesn't give a precise definition of |
Describe the bug
Fixed length strings are copied to
H5std_string
(std::string
) as if they were null terminated C strings. This incorrect if the fixed length string contains embedded null bytes.This is because
string& operator= (const char* s)
is used on line 732 here:hdf5/c++/src/H5DataSet.cpp
Lines 711 to 735 in 81bc34a
Expected behavior
Fixed length strings with embedded null bytes should be correctly read into the
std::string
.Line 732 should probably be
Platform (please complete the following information)
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: