From 52cc97f6b477c3f5bb1b79c75db43e51e100dec3 Mon Sep 17 00:00:00 2001 From: Jelte Jansen Date: Mon, 23 Nov 2009 09:47:13 +0000 Subject: [PATCH] Merged to_wire nulltermination bugfix from branches/jelte-datadef revision 297:298 git-svn-id: svn://bind10.isc.org/svn/bind10/branches/parkinglot@319 e5f2f494-b856-4b98-b285-d166d9295462 --- src/lib/cc/cpp/data.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/cc/cpp/data.cc b/src/lib/cc/cpp/data.cc index 2f409547af..6c7f9126f2 100644 --- a/src/lib/cc/cpp/data.cc +++ b/src/lib/cc/cpp/data.cc @@ -739,17 +739,19 @@ encode_length(unsigned int length, unsigned char type) type |= ITEM_LENGTH_8; ss << type << val; } else if (length <= 0x0000ffff) { - unsigned char val[2]; + unsigned char val[3]; val[0] = (length & 0x0000ff00) >> 8; val[1] = (length & 0x000000ff); + val[2] = 0; type |= ITEM_LENGTH_16; ss << type << val; } else { - unsigned char val[4]; + unsigned char val[5]; val[0] = (length & 0xff000000) >> 24; val[1] = (length & 0x00ff0000) >> 16; val[2] = (length & 0x0000ff00) >> 8; val[3] = (length & 0x000000ff); + val[4] = 0; type |= ITEM_LENGTH_32; ss << type << val; }