diff --git a/encrypt.cpp b/encrypt.cpp index 055a8bb..d6dd96c 100755 --- a/encrypt.cpp +++ b/encrypt.cpp @@ -48,8 +48,8 @@ int my_encrypt(const char *data0,char *output,int &len,char * key) if(len>65535) return -1; - data[len-16-2]=(uint16_t(ori_len))>>8; - data[len-16-1]=((uint16_t(ori_len))<<8)>>8; + data[len-16-2]= (unsigned char)( (uint16_t(ori_len))>>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]); @@ -108,7 +108,7 @@ int my_decrypt(const char *data0,char *output,int &len,char * key) 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; } diff --git a/main.cpp b/main.cpp index 581c4b6..cd39d62 100755 --- a/main.cpp +++ b/main.cpp @@ -1897,6 +1897,9 @@ int recv_safer(packet_info_t &info,char* &data,int &len) return -1; } + + //printf("recv _len %d\n ",recv_len); + //printf("222222222222222\n"); @@ -1917,12 +1920,14 @@ int recv_safer(packet_info_t &info,char* &data,int &len) 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 ); + if(len<0) { - printf("len <0\n"); + printf("len <0 ,%d\n",len); return -1; }