From ec7fcffcb5943065be09f21252520a813143b435 Mon Sep 17 00:00:00 2001 From: joss17 Date: Sun, 31 Jan 2010 20:17:15 +0000 Subject: [PATCH] fix a possible bug in getTlvString git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2166 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/serialiser/rstlvbase.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libretroshare/src/serialiser/rstlvbase.cc b/libretroshare/src/serialiser/rstlvbase.cc index 2f64ffff3..d407edd62 100644 --- a/libretroshare/src/serialiser/rstlvbase.cc +++ b/libretroshare/src/serialiser/rstlvbase.cc @@ -449,7 +449,11 @@ bool GetTlvString(void *data, uint32_t size, uint32_t *offset, char *strdata = (char *) right_shift_void_pointer(tlvstart, TLV_HEADER_SIZE); uint16_t strsize = tlvsize - TLV_HEADER_SIZE; /* remove the header */ - in = std::string(strdata, strsize); + if (strsize <= 0) { + in = ""; + } else { + in = std::string(strdata, strsize); + } *offset += tlvsize; /* step along */ return true;