Compare commits

...

15 Commits

Author SHA1 Message Date
HiGarfield
3dc19b7994 Merge ee1e4d33f8 into f49e6adedf 2023-11-07 11:43:51 +08:00
yancey
f49e6adedf remove Dockerfile 2023-11-06 03:19:46 -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
yancey
d1a9bcc4fb try to fix linux 6.5 compile 2023-10-07 08:26:10 -04:00
Yancey Wang
bc8bd8c2f8 Merge pull request #475 from gek64/unified
Fix compile errors on FreeBSD/pfSense/OPNsense
2023-09-21 16:35:45 -04:00
gek64
ca16c3a5e6 Merge branch 'wangyu-:unified' into unified 2023-07-27 21:10:28 +08:00
Yancey Wang
7abe19c7d9 Merge pull request #482 from wangyu-/revert-455-unified
Revert "fix CMakeLists.txt"
2023-07-22 17:31:10 -04:00
Yancey Wang
f3f528e866 Revert "fix CMakeLists.txt" 2023-07-22 17:30:56 -04:00
Yancey Wang
ec6fad552b Merge pull request #455 from HiGarfield/unified
fix CMakeLists.txt
2023-07-22 17:09:53 -04:00
yancey
87b878a09e fix stack-use-after-scope reported by sanitizer 2023-07-22 14:31:17 -04:00
yancey
e66eddd1d5 fix mem access problem reported by sanitizer 2023-07-22 14:00:03 -04:00
gek64
ec416515f3 Fix compile errors on freebsd 2023-06-14 16:26:10 +08:00
Yancey Wang
d12e540830 Update CMakeLists.txt 2023-06-04 21:44:44 -04:00
Yancey Wang
e7eecc8ef2 Update ISSUE_TEMPLATE.md 2023-05-10 00:08:00 -04:00
HiGarfield
82ba4f7d1b fix CMakeLists.txt 2023-02-09 01:23:51 +08:00
8 changed files with 19 additions and 28 deletions

View File

@@ -1,4 +1,7 @@
#note: experimental
# currently only used for generating `compile_commands.json` for clangd.
# to build this project, it's suggested to use `makefile` instead
cmake_minimum_required(VERSION 3.7)
project(udp2raw)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

View File

@@ -1,13 +0,0 @@
FROM alpine:3.6 as builder
WORKDIR /
RUN apk add --no-cache git build-base linux-headers && \
git clone https://github.com/wangyu-/udp2raw-tunnel.git && \
cd udp2raw-tunnel && \
make dynamic
FROM alpine:3.6
RUN apk add --no-cache libstdc++ iptables
COPY --from=builder /udp2raw-tunnel/udp2raw_dynamic /bin/
ENTRYPOINT [ "/bin/udp2raw_dynamic" ]

View File

@@ -1 +1 @@
English Only (except for bug reporting).
English Only.

View File

@@ -1127,8 +1127,8 @@ void print_binary_chars(const char *a, int len) {
u32_t djb2(unsigned char *str, int len) {
u32_t hash = 5381;
int c;
int i = 0;
while (c = *str++, i++ != len) {
for (int i=0; i<len ;i++) {
c = *(str++);
hash = ((hash << 5) + hash) ^ c; /* (hash * 33) ^ c */
}
@@ -1139,8 +1139,8 @@ u32_t djb2(unsigned char *str, int len) {
u32_t sdbm(unsigned char *str, int len) {
u32_t hash = 0;
int c;
int i = 0;
while (c = *str++, i++ != len) {
for (int i=0; i<len ;i++) {
c = *(str++);
hash = c + (hash << 6) + (hash << 16) - hash;
}
// hash=htonl(hash);

View File

@@ -40,19 +40,19 @@ int main(int argc, char *argv[]) {
pre_process_arg(argc, argv);
ev_signal signal_watcher_sigpipe;
ev_signal signal_watcher_sigterm;
ev_signal signal_watcher_sigint;
if (program_mode == client_mode) {
struct ev_loop *loop = ev_default_loop(0);
#if !defined(__MINGW32__)
ev_signal signal_watcher_sigpipe;
ev_signal_init(&signal_watcher_sigpipe, sigpipe_cb, SIGPIPE);
ev_signal_start(loop, &signal_watcher_sigpipe);
#endif
ev_signal signal_watcher_sigterm;
ev_signal_init(&signal_watcher_sigterm, sigterm_cb, SIGTERM);
ev_signal_start(loop, &signal_watcher_sigterm);
ev_signal signal_watcher_sigint;
ev_signal_init(&signal_watcher_sigint, sigint_cb, SIGINT);
ev_signal_start(loop, &signal_watcher_sigint);
} else {

View File

@@ -103,7 +103,7 @@ linux:git_version
${cc_local} -o ${NAME}_$@ -I. ${SOURCES} ${PCAP} ${FLAGS} -lrt -ggdb -static -O2 ${MP}
freebsd:git_version
${cc_local} -o ${NAME}_$@ -I. ${SOURCES} ${PCAP} ${FLAGS} -lrt -ggdb -static -O2 ${MP}
${cc_local} -o ${NAME}_$@ -I. ${SOURCES} ${PCAP} ${FLAGS} -lrt -ggdb -static -libverbs -O2 ${MP}
mac:git_version
${cc_local} -o ${NAME}_$@ -I. ${SOURCES} ${PCAP} ${FLAGS} -ggdb -O2 ${MP}

View File

@@ -702,7 +702,7 @@ void init_filter(int port) {
}
}
int dummy;
int dummy=0;
int ret = setsockopt(raw_recv_fd, SOL_SOCKET, SO_DETACH_FILTER, &dummy, sizeof(dummy)); // in case i forgot to remove
if (ret != 0) {
@@ -841,7 +841,7 @@ void init_filter(int port) {
void remove_filter() {
filter_port = 0;
#ifdef UDP2RAW_LINUX
int dummy;
int dummy=0;
int ret = setsockopt(raw_recv_fd, SOL_SOCKET, SO_DETACH_FILTER, &dummy, sizeof(dummy));
if (ret != 0) {
mylog(log_debug, "error remove fiter\n");
@@ -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;

View File

@@ -226,12 +226,12 @@ struct packet_info_t // todo change this to union
bool has_ts;
i32_t data_len;
#ifdef UDP2RAW_LINUX
sockaddr_ll addr_ll;
#endif
i32_t data_len;
packet_info_t();
};