From 3cfe69787f0c7b59ce0ee42aa246c9c02233ec42 Mon Sep 17 00:00:00 2001 From: AsamK Date: Wed, 2 Sep 2015 02:03:46 +0200 Subject: [PATCH] Fix subtle bug in tlv deserialization of TLV_TYPE_KEYSIGNATURETYPE When using -O2, the variable currType is optimized out, so the signature is added with the wrong sign type. Then when verifying the data the signature is not found and verification fails. The main sympton of this bug was receiving no more forum/channel posts. Wit debug builds (-O0) this worked, that's why not every one was affected by this. This bug was introduced in 2012 (19e856c2a8eb56c5e43e977aac27a3dbc79ab2d0) --- libretroshare/src/serialiser/rstlvkeys.cc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/libretroshare/src/serialiser/rstlvkeys.cc b/libretroshare/src/serialiser/rstlvkeys.cc index eb90fff52..968b09d83 100644 --- a/libretroshare/src/serialiser/rstlvkeys.cc +++ b/libretroshare/src/serialiser/rstlvkeys.cc @@ -649,7 +649,6 @@ bool RsTlvKeySignatureSet::GetTlv(void *data, uint32_t size, uint32_t *offset) /* get the next type */ uint16_t tlvsubtype = GetTlvType( &(((uint8_t *) data)[*offset]) ); - SignType currType; switch(tlvsubtype) { @@ -659,16 +658,13 @@ bool RsTlvKeySignatureSet::GetTlv(void *data, uint32_t size, uint32_t *offset) ok &= sign.GetTlv(data, size, offset); if (ok) { - keySignSet[currType] = sign; + keySignSet[sign_type] = sign; } } break; case TLV_TYPE_KEYSIGNATURETYPE: { ok = GetTlvUInt32(data, size, offset, TLV_TYPE_KEYSIGNATURETYPE, &sign_type); - - if(ok) - currType = sign_type; } break; default: