Compare commits

..

2 Commits

Author SHA1 Message Date
HiGarfield
6303ce2387 Merge ee1e4d33f8 into e42f0e5732 2023-11-16 00:48:31 -05:00
HiGarfield
ee1e4d33f8 fix possible null pointer dereference
cppcheck reports:
network.cpp:1717:22: error: Null pointer dereference: payload [ctunullpointer]
    memcpy(tcp_data, payload, payloadlen);
                     ^
client.cpp:193:22: note: Calling function send_raw0, 2nd argument is null
            send_raw0(raw_info, 0, 0);
                     ^
network.cpp:2534:20: note: Calling function send_raw_tcp, 2nd argument is null
            return send_raw_tcp(raw_info, payload, payloadlen);
                   ^
network.cpp:1717:22: note: Dereferencing argument payload that is null
    memcpy(tcp_data, payload, payloadlen);
                     ^
2023-10-08 11:37:35 +08:00
2 changed files with 4 additions and 3 deletions

View File

@@ -435,7 +435,7 @@ int send_safer(conn_info_t &conn_info, char type, const char *data, int len) //
if (cipher_mode == cipher_xor) {
send_data_buf2[0] ^= gro_xor[0];
send_data_buf2[1] ^= gro_xor[1];
} else if (cipher_mode == cipher_aes128cbc || cipher_mode == cipher_aes128cfb) {
} else if (cipher_mode == cipher_aes128cbc || cipher_mode == cipher_aes128cbc) {
aes_ecb_encrypt1(send_data_buf2);
}
}
@@ -586,7 +586,7 @@ int recv_safer_multi(conn_info_t &conn_info, vector<char> &type_arr, vector<stri
if (cipher_mode == cipher_xor) {
recv_data[0] ^= gro_xor[0];
recv_data[1] ^= gro_xor[1];
} else if (cipher_mode == cipher_aes128cbc || cipher_mode == cipher_aes128cfb) {
} else if (cipher_mode == cipher_aes128cbc || cipher_mode == cipher_aes128cbc) {
aes_ecb_decrypt1(recv_data);
}
single_len = read_u16(recv_data);

View File

@@ -1714,6 +1714,7 @@ int send_raw_tcp(raw_info_t &raw_info, const char *payload, int payloadlen) { /
char *tcp_data = send_raw_tcp_buf + +tcph->doff * 4;
if (payload)
memcpy(tcp_data, payload, payloadlen);
int tcp_totlen = tcph->doff * 4 + payloadlen;