@@ -29,7 +29,8 @@ extern "C"
29
29
{
30
30
sections[i].name =
31
31
(char *)malloc (strlen (internalSections[i].name .c_str ()) + 1 );
32
- strcpy (sections[i].name , internalSections[i].name .c_str ());
32
+ strncpy (sections[i].name , internalSections[i].name .c_str (),
33
+ internalSections[i].name .size ());
33
34
34
35
sections[i].lines = (KeyValuePairInternal *)malloc (
35
36
internalSections[i].lines .size () *
@@ -41,16 +42,18 @@ extern "C"
41
42
{
42
43
sections[i].lines [j].key = (char *)malloc (
43
44
strlen (internalSections[i].lines [j].first .c_str ()) + 1 );
44
- strcpy (sections[i].lines [j].key ,
45
- internalSections[i].lines [j].first .c_str ());
45
+ strncpy (sections[i].lines [j].key ,
46
+ internalSections[i].lines [j].first .c_str (),
47
+ internalSections[i].lines [j].first .size ());
46
48
47
49
auto values = internalSections[i].lines [j].second ;
48
50
49
51
for (auto k = 0 ; k < values.size (); k += 1 )
50
52
{
51
53
sections[i].lines [j].values [k] =
52
54
(char *)malloc (strlen (values[k].c_str ()) + 1 );
53
- strcpy (sections[i].lines [j].values [k], values[k].c_str ());
55
+ strncpy (sections[i].lines [j].values [k], values[k].c_str (),
56
+ values[k].size ());
54
57
}
55
58
56
59
sections[i].lines [j].valueCount = values.size ();
0 commit comments