ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
April 17th, 2024 | 14:30-16:00 SGT (UTC+8) | Online

Wireshark-dev: Re: [Wireshark-dev] Problem during compilation

From: Graham Bloice <graham.bloice@xxxxxxxxxxxxx>
Date: Mon, 26 Apr 2010 10:35:08 +0100
On 26/04/2010 10:10, ankur madan wrote:
I have latest version code from the svn and latest development wireshark version.1.3.4 installed.i am still not able to resolve this issue.any help or comments are welcome
 
thanks
ankur

On Mon, Apr 26, 2010 at 12:51 PM, ankur madan <ankurmadan9@xxxxxxxxx> wrote:
I am compiling on windows XP n 32 bit.


On Mon, Apr 26, 2010 at 3:37 AM, Stephen Fisher <steve@xxxxxxxxxxxxxxxxxx> wrote:
On Fri, Apr 23, 2010 at 02:42:35PM +0530, ankur madan wrote:

> packet-ieee802154.c(982) : warning C4244: '=' : conversion from
> 'guint64' to 'gu int32', possible loss of data

I see that you're compiling on Windows, but which version and is it
32-bit or 64-bit?


Personally I'm just carrying fixes to this in my local source tree as I haven't had time to push a patch back into the repo.  I don't know why this compiles OK on the buildbot and not with VC8.

IMHO the current code is incorrect as it incorrectly casts a 32 bit value to a 64 bit one and then calls proto_tree_add_uint64 with it when the value really is a 32 bit one (lines 981-985):

        if (packet->key_id_mode == KEY_ID_MODE_KEY_EXPLICIT_4) {
          packet->key_source.addr32 = tvb_get_ntohl(tvb, offset);
          proto_tree_add_uint64(field_tree, hf_ieee802154_aux_sec_key_source, tvb, offset, 4, packet->key_source.addr32);
          proto_item_set_len(ti, 1 + 4);
          offset += sizeof (guint32);

and the other errors simply need a cast to gchar to allow them to compile (lines 2006 - 2013).

I've attached a patch that works for me.

-- 
Regards,

Graham Bloice
Index: packet-ieee802154.c
===================================================================
--- packet-ieee802154.c	(revision 32563)
+++ packet-ieee802154.c	(working copy)
@@ -979,8 +979,8 @@
         field_tree = proto_item_add_subtree(ti, ett_ieee802154_aux_sec_key_id);
         /* Add key source, if it exists. */
         if (packet->key_id_mode == KEY_ID_MODE_KEY_EXPLICIT_4) {
-          packet->key_source.addr32 = (guint64) tvb_get_ntohl(tvb, offset);
-          proto_tree_add_uint64(field_tree, hf_ieee802154_aux_sec_key_source, tvb, offset, 4, packet->key_source.addr32);
+          packet->key_source.addr32 = tvb_get_ntohl(tvb, offset);
+          proto_tree_add_uint32(field_tree, hf_ieee802154_aux_sec_key_source, tvb, offset, 4, packet->key_source.addr32);
           proto_item_set_len(ti, 1 + 4);
           offset += sizeof (guint32);
         }
@@ -2003,14 +2003,14 @@
     if (adata) block[i] |= (1 << 6); /* Adata */
     i++;
     /* Nonce: Source Address || Frame Counter || Security Level */
-    block[i++] = (addr >> 56) & 0xff;
-    block[i++] = (addr >> 48) & 0xff;
-    block[i++] = (addr >> 40) & 0xff;
-    block[i++] = (addr >> 32) & 0xff;
-    block[i++] = (addr >> 24) & 0xff;
-    block[i++] = (addr >> 16) & 0xff;
-    block[i++] = (addr >> 8) & 0xff;
-    block[i++] = (addr >> 0) & 0xff;
+    block[i++] = (gchar)((addr >> 56) & 0xff);
+    block[i++] = (gchar)((addr >> 48) & 0xff);
+    block[i++] = (gchar)((addr >> 40) & 0xff);
+    block[i++] = (gchar)((addr >> 32) & 0xff);
+    block[i++] = (gchar)((addr >> 24) & 0xff);
+    block[i++] = (gchar)((addr >> 16) & 0xff);
+    block[i++] = (gchar)((addr >> 8) & 0xff);
+    block[i++] = (gchar)((addr >> 0) & 0xff);
     block[i++] = (counter >> 24) & 0xff;
     block[i++] = (counter >> 16) & 0xff;
     block[i++] = (counter >> 8) & 0xff;