WBXML: add a basic sanity check for offset overflow

This is a naive approach allowing to detact that something went wrong,
without the need to replace all proto_tree_add_text() calls as what was
done in master-2.0 branch.

Bug: 12408
Change-Id: Ia14905005e17ae322c2fc639ad5e491fa08b0108
Reviewed-on: https://code.wireshark.org/review/15310
Reviewed-by: Michael Mann <mmann78@netscape.net>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
emnc10_opaque_binary_attr(tvbuff_t *tvb, guint32 offset,
			  guint8 token, guint8 codepage, guint32 *length)
{
	guint32 data_len = tvb_get_guintvar(tvb, offset, length);
	char *str = NULL;

	switch (codepage) {
	case 0: /* Only valid codepage for EMN */
		switch (token) {
		case 0x05: /* timestamp= */
			str = date_time_from_opaque(tvb,
						    offset + *length, data_len);
			break;
		default:
			break;
		}
		break;
	default:
		break;
	}
	if (str == NULL) { /* Error, or not parsed */
		str = wmem_strdup_printf(wmem_packet_scope(), "(%d bytes of unparsed opaque data)", data_len);
	}
	*length += data_len;

	return str;
}

emnc10_opaque_binary_attr(tvbuff_t *tvb, guint32 offset,
			  guint8 token, guint8 codepage, guint32 *length)
{
	guint32 data_len = tvb_get_guintvar(tvb, offset, length);
	char *str = NULL;

	switch (codepage) {
	case 0: /* Only valid codepage for EMN */
		switch (token) {
		case 0x05: /* timestamp= */
			str = date_time_from_opaque(tvb,
						    offset + *length, data_len);
			break;
		default:
			break;
		}
		break;
	default:
		break;
	}
	if (str == NULL) { /* Error, or not parsed */
		str = wmem_strdup_printf(wmem_packet_scope(), "(%d bytes of unparsed opaque data)", data_len);
	}
	*length += data_len;

	return str;
}
