Commit b6571be9 authored by Jelte Jansen's avatar Jelte Jansen
Browse files

unsigned char arrays interpreted as strings are still null-terminated in c++


git-svn-id: svn://bind10.isc.org/svn/bind10/branches/jelte-datadef@298 e5f2f494-b856-4b98-b285-d166d9295462
parent 3a19a908
...@@ -735,17 +735,19 @@ encode_length(unsigned int length, unsigned char type) ...@@ -735,17 +735,19 @@ encode_length(unsigned int length, unsigned char type)
type |= ITEM_LENGTH_8; type |= ITEM_LENGTH_8;
ss << type << val; ss << type << val;
} else if (length <= 0x0000ffff) { } else if (length <= 0x0000ffff) {
unsigned char val[2]; unsigned char val[3];
val[0] = (length & 0x0000ff00) >> 8; val[0] = (length & 0x0000ff00) >> 8;
val[1] = (length & 0x000000ff); val[1] = (length & 0x000000ff);
val[2] = 0;
type |= ITEM_LENGTH_16; type |= ITEM_LENGTH_16;
ss << type << val; ss << type << val;
} else { } else {
unsigned char val[4]; unsigned char val[5];
val[0] = (length & 0xff000000) >> 24; val[0] = (length & 0xff000000) >> 24;
val[1] = (length & 0x00ff0000) >> 16; val[1] = (length & 0x00ff0000) >> 16;
val[2] = (length & 0x0000ff00) >> 8; val[2] = (length & 0x0000ff00) >> 8;
val[3] = (length & 0x000000ff); val[3] = (length & 0x000000ff);
val[4] = 0;
type |= ITEM_LENGTH_32; type |= ITEM_LENGTH_32;
ss << type << val; ss << type << val;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment