mirror of
https://github.com/Waujito/youtubeUnblock.git
synced 2024-12-22 06:15:31 +00:00
Fix memcpy
This commit is contained in:
parent
5415bc37ec
commit
2fd3107401
16
kmod_utils.c
16
kmod_utils.c
@ -65,16 +65,8 @@ static int send_raw_ipv4(const uint8_t *pkt, uint32_t pktlen) {
|
|||||||
|
|
||||||
memset(&msg, 0, sizeof(msg));
|
memset(&msg, 0, sizeof(msg));
|
||||||
|
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)
|
|
||||||
iov.iov_base = (__u8 *)pkt;
|
iov.iov_base = (__u8 *)pkt;
|
||||||
iov.iov_len = pktlen;
|
iov.iov_len = pktlen;
|
||||||
iov_iter_kvec(&msg.msg_iter, READ, &iov, 1, 1);
|
|
||||||
#else
|
|
||||||
iov.iov_base = (__u8 *)pkt;
|
|
||||||
iov.iov_len = pktlen;
|
|
||||||
// msg.msg_iov = (struct iovec *)&iov;
|
|
||||||
// msg.msg_iovlen = iov.iov_len;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
msg.msg_flags = 0;
|
msg.msg_flags = 0;
|
||||||
msg.msg_name = &daddr;
|
msg.msg_name = &daddr;
|
||||||
@ -133,16 +125,8 @@ int send_raw_ipv6(const uint8_t *pkt, uint32_t pktlen) {
|
|||||||
struct msghdr msg;
|
struct msghdr msg;
|
||||||
memset(&msg, 0, sizeof(msg));
|
memset(&msg, 0, sizeof(msg));
|
||||||
|
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)
|
|
||||||
iov.iov_base = (__u8 *)pkt;
|
iov.iov_base = (__u8 *)pkt;
|
||||||
iov.iov_len = pktlen;
|
iov.iov_len = pktlen;
|
||||||
iov_iter_kvec(&msg.msg_iter, READ, &iov, 1, 1);
|
|
||||||
#else
|
|
||||||
iov.iov_base = (__u8 *)pkt;
|
|
||||||
iov.iov_len = pktlen;
|
|
||||||
// msg.msg_iov = (struct iovec *)&iov;
|
|
||||||
// msg.msg_iovlen = iov.iov_len;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
msg.msg_flags = 0;
|
msg.msg_flags = 0;
|
||||||
msg.msg_name = &daddr;
|
msg.msg_name = &daddr;
|
||||||
|
7
mangle.c
7
mangle.c
@ -1037,7 +1037,12 @@ int fail_packet(uint8_t *payload, uint32_t *plen, uint32_t avail_buflen) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
uint8_t *ndata = data + delta;
|
uint8_t *ndata = data + delta;
|
||||||
memcpy(ndata, data, dlen);
|
uint8_t *ndptr = ndata + dlen;
|
||||||
|
uint8_t *dptr = data + dlen;
|
||||||
|
for (size_t i = dlen + 1; i > 0; i--) {
|
||||||
|
*ndptr = *dptr;
|
||||||
|
--ndptr, --dptr;
|
||||||
|
}
|
||||||
data = ndata;
|
data = ndata;
|
||||||
tcph_len = tcph_len + delta;
|
tcph_len = tcph_len + delta;
|
||||||
tcph->doff = tcph_len >> 2;
|
tcph->doff = tcph_len >> 2;
|
||||||
|
2
types.h
2
types.h
@ -93,7 +93,7 @@ typedef __u64 uint64_t;
|
|||||||
*/
|
*/
|
||||||
#ifdef KERNEL_SPACE
|
#ifdef KERNEL_SPACE
|
||||||
#include <linux/gfp.h>
|
#include <linux/gfp.h>
|
||||||
#define NETBUF_ALLOC(buf, buf_len) __u8* buf = kmalloc(buf_len, GFP_ATOMIC);
|
#define NETBUF_ALLOC(buf, buf_len) __u8* buf = kmalloc(buf_len, GFP_KERNEL);
|
||||||
#define NETBUF_CHECK(buf) ((buf) != NULL)
|
#define NETBUF_CHECK(buf) ((buf) != NULL)
|
||||||
#define NETBUF_FREE(buf) kfree(buf);
|
#define NETBUF_FREE(buf) kfree(buf);
|
||||||
#elif defined(ALLOC_MALLOC)
|
#elif defined(ALLOC_MALLOC)
|
||||||
|
Loading…
Reference in New Issue
Block a user