corrected handling of null strings in RsTlvBase::GetTlvString()

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2766 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2010-04-23 13:42:01 +00:00
parent 0d533d14b1
commit d027af3324
2 changed files with 15 additions and 3 deletions

View File

@ -138,7 +138,7 @@ bool SkipUnknownTlv(void *data, uint32_t size, uint32_t *offset)
/* extract the type and size */
void *tlvstart = right_shift_void_pointer(data, *offset);
uint16_t tlvtype = GetTlvType(tlvstart);
//uint16_t tlvtype = GetTlvType(tlvstart);
uint32_t tlvsize = GetTlvSize(tlvstart);
/* check that there is size */
@ -409,7 +409,15 @@ bool GetTlvString(void *data, uint32_t size, uint32_t *offset,
if (!data)
return false;
if (size < *offset + TLV_HEADER_SIZE)
// Check if we have a null string (this happens with certs)
//
if (size == *offset)
{
in = "" ;
return true ;
}
if (size < *offset)
{
#ifdef TLV_BASE_DEBUG
std::cerr << "GetTlvString() FAILED - not enough space" << std::endl;

View File

@ -427,7 +427,11 @@ bool RsTlvKeySignature::GetTlv(void *data, uint32_t size, uint32_t *offset) /*
ok &= GetTlvString(data, tlvend, offset, TLV_TYPE_STR_KEYID, keyId);
ok &= signData.GetTlv(data, tlvend, offset);
ok &= GetTlvString(data, tlvend, offset, TLV_TYPE_STR_CERT_SSL, sslCert);
// The ssl cert is possibly void, i.e. an empty string. This is handled by
// GetTlvString().
//
ok &= GetTlvString(data, tlvend, offset, TLV_TYPE_STR_CERT_SSL, sslCert);
/***************************************************************************
* NB: extra components could be added (for future expansion of the type).