Closed GoogleCodeExporter closed 8 years ago
I don't know wry, but I was sure that a char is an unsignet 8-bit value type,
exactly like a byte... but looks that isn't the case:
http://msdn.microsoft.com/en-us/library/7sx7t66b(v=vs.120).aspx
So I think that maybe reading 11 chars can generate an "overflow", i.e: reading
outsite the extent of "name" field.
I'm right?
Original comment by diegogu...@gmail.com
on 15 Nov 2013 at 4:04
fixed with changeset
1081:https://code.google.com/p/nettopologysuite/source/detail?r=1081
Original comment by diegogu...@gmail.com
on 15 Nov 2013 at 4:15
thanks for reporting this
Original comment by diegogu...@gmail.com
on 15 Nov 2013 at 4:16
This is a same bug whih the WriteHeader method
// write the field name
for (int j = 0; j < FieldNameMaxLength; j++)
{
if (_fieldDescriptions[i].Name.Length > j)
writer.Write((byte)_fieldDescriptions[i].Name[j]);
else writer.Write((byte)0);
}
the field name bytes value should read by the _encoding member:
byte[] buffer = _encoding.GetBytes(_fieldDescriptions[i].Name)
then check the length of the buffer
Original comment by roc....@gmail.com
on 16 Nov 2013 at 1:00
[deleted comment]
[deleted comment]
char store length depends on the encoding..
Original comment by roc....@gmail.com
on 16 Nov 2013 at 2:05
please take a look at commit 1082:
https://code.google.com/p/nettopologysuite/source/detail?r=1082
Original comment by diegogu...@gmail.com
on 17 Nov 2013 at 10:43
There are still a bug, the field name is just 11 bytes, need check that.
Original comment by roc....@gmail.com
on 17 Nov 2013 at 11:15
[deleted comment]
now should be ok https://code.google.com/p/nettopologysuite/source/detail?r=1085
Original comment by diegogu...@gmail.com
on 17 Nov 2013 at 1:33
i.e
// write the field name
string fieldName = _fieldDescriptions[i].Name;
while (_encoding.GetByteCount(fieldName) > 11)
fieldName = fieldName.Substring(0, fieldName.Length - 1);
writer.Write(_encoding.GetBytes(fieldName));
Original comment by roc....@gmail.com
on 18 Nov 2013 at 11:36
[deleted comment]
[deleted comment]
Sorry, It's should like:
// write the field name
string fieldName = _fieldDescriptions[i].Name;
// make sure the field name data length is not bigger than 11
while (_encoding.GetByteCount(fieldName) > 11)
fieldName = fieldName.Substring(0, fieldName.Length - 1);
byte[] buffer = new byte[11];
byte[] nameData = _encoding.GetBytes(fieldName);
Array.Copy(nameData, buffer, nameData.Length);
writer.Write(buffer);
Original comment by roc....@gmail.com
on 18 Nov 2013 at 12:23
hope the code it's right now :)
https://code.google.com/p/nettopologysuite/source/detail?r=1086
Original comment by diegogu...@gmail.com
on 18 Nov 2013 at 1:26
Original issue reported on code.google.com by
roc....@gmail.com
on 15 Nov 2013 at 1:02