mirror of
https://github.com/wangyu-/udp2raw.git
synced 2025-01-19 22:39:31 +08:00
fix the bug caused by sign
This commit is contained in:
parent
bf449634f1
commit
8ecb55d845
@ -48,8 +48,8 @@ int my_encrypt(const char *data0,char *output,int &len,char * key)
|
|||||||
|
|
||||||
if(len>65535) return -1;
|
if(len>65535) return -1;
|
||||||
|
|
||||||
data[len-16-2]=(uint16_t(ori_len))>>8;
|
data[len-16-2]= (unsigned char)( (uint16_t(ori_len))>>8);
|
||||||
data[len-16-1]=((uint16_t(ori_len))<<8)>>8;
|
data[len-16-1]=(unsigned char)( ((uint16_t(ori_len))<<8)>>8) ;
|
||||||
|
|
||||||
|
|
||||||
//printf("%d %d\n",data[len-16-2],data[len-16-1]);
|
//printf("%d %d\n",data[len-16-2],data[len-16-1]);
|
||||||
@ -108,7 +108,7 @@ int my_decrypt(const char *data0,char *output,int &len,char * key)
|
|||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
len=output[len-16-2]*256u+output[len-16-1];
|
len=((unsigned char)output[len-16-2])*256u+((unsigned char)output[len-16-1]); //this may be broken because of sign
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
9
main.cpp
9
main.cpp
@ -1897,6 +1897,9 @@ int recv_safer(packet_info_t &info,char* &data,int &len)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//printf("recv _len %d\n ",recv_len);
|
||||||
|
|
||||||
//printf("222222222222222\n");
|
//printf("222222222222222\n");
|
||||||
|
|
||||||
|
|
||||||
@ -1917,12 +1920,14 @@ int recv_safer(packet_info_t &info,char* &data,int &len)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
data=recv_data_buf+sizeof(anti_replay_seq_t)+sizeof(id_t)*2;;
|
//printf("recv _len %d\n ",recv_len);
|
||||||
|
data=recv_data_buf+sizeof(anti_replay_seq_t)+sizeof(id_t)*2;
|
||||||
len=recv_len-(sizeof(anti_replay_seq_t)+sizeof(id_t)*2 );
|
len=recv_len-(sizeof(anti_replay_seq_t)+sizeof(id_t)*2 );
|
||||||
|
|
||||||
|
|
||||||
if(len<0)
|
if(len<0)
|
||||||
{
|
{
|
||||||
printf("len <0\n");
|
printf("len <0 ,%d\n",len);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user