mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-31 08:25:22 +00:00
fixed MDP frame relevent byte calculation to work regardless of what
weird alignment foo the compiler decides to do.
This commit is contained in:
parent
90a1317822
commit
44ad4db147
@ -914,33 +914,28 @@ int overlay_mdp_relevant_bytes(overlay_mdp_frame *mdp)
|
||||
int len=4;
|
||||
switch(mdp->packetTypeAndFlags&MDP_TYPE_MASK)
|
||||
{
|
||||
case MDP_ADDRLIST: len=4
|
||||
+sizeof(mdp->addrlist.frame_sid_count)
|
||||
+sizeof(mdp->addrlist.first_sid)
|
||||
+sizeof(mdp->addrlist.last_sid)
|
||||
+sizeof(mdp->addrlist.server_sid_count)
|
||||
+mdp->addrlist.frame_sid_count*SID_SIZE;
|
||||
case MDP_ADDRLIST:
|
||||
len=&mdp->addrlist.sids[0][0]-(unsigned char *)mdp;
|
||||
len+=mdp->addrlist.frame_sid_count*SID_SIZE;
|
||||
printf("%d sids takes 0x%x bytes\n",mdp->addrlist.frame_sid_count,len);
|
||||
break;
|
||||
case MDP_GETADDRS: len=4
|
||||
+sizeof(mdp->addrlist.frame_sid_count)
|
||||
+sizeof(mdp->addrlist.first_sid)
|
||||
+sizeof(mdp->addrlist.last_sid)
|
||||
+sizeof(mdp->addrlist.server_sid_count);
|
||||
case MDP_GETADDRS:
|
||||
len=&mdp->addrlist.sids[0][0]-(unsigned char *)mdp;
|
||||
break;
|
||||
case MDP_TX:
|
||||
len=4+sizeof(mdp->out)
|
||||
-sizeof(mdp->out.payload)
|
||||
+mdp->out.payload_length;
|
||||
len=&mdp->out.payload[0]-(unsigned char *)mdp;
|
||||
len+=mdp->out.payload_length;
|
||||
break;
|
||||
case MDP_RX:
|
||||
len=4+sizeof(mdp->in)
|
||||
-sizeof(mdp->in.payload)
|
||||
+mdp->in.payload_length; break;
|
||||
case MDP_BIND: len=4+sizeof(mdp->bind); break;
|
||||
len=&mdp->in.payload[0]-(unsigned char *)mdp;
|
||||
len+=mdp->in.payload_length;
|
||||
case MDP_BIND:
|
||||
len=&mdp->bind.sid[SID_SIZE]-(unsigned char *)mdp;
|
||||
case MDP_ERROR:
|
||||
/* This formulation is used so that we don't copy any bytes after the
|
||||
end of the string, to avoid information leaks */
|
||||
len=4+4+strlen(mdp->error.message)+1; break;
|
||||
len=&mdp->error.message[0]-(char *)mdp;
|
||||
len+=strlen(mdp->error.message)+1; break;
|
||||
default:
|
||||
return WHY("Illegal MDP frame type.");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user