From 93e91dab66a2370208e12b55d5cefb15c4372881 Mon Sep 17 00:00:00 2001 From: lededev <30518126+lededev@users.noreply.github.com> Date: Sat, 4 Nov 2023 07:39:22 +0800 Subject: [PATCH 1/4] fix gcc13 warning pointer used after free() --- .../patches/104-pointer-used-after-free.patch | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 shadowsocksr-libev/patches/104-pointer-used-after-free.patch diff --git a/shadowsocksr-libev/patches/104-pointer-used-after-free.patch b/shadowsocksr-libev/patches/104-pointer-used-after-free.patch new file mode 100644 index 000000000..b1ce790ab --- /dev/null +++ b/shadowsocksr-libev/patches/104-pointer-used-after-free.patch @@ -0,0 +1,31 @@ +diff -ur a/server/server.c b/server/server.c +--- a/server/server.c ++++ b/server/server.c +@@ -1942,12 +1942,12 @@ + text = (char*)malloc(strlen(protocol) - 11); + memcpy(text, protocol, strlen(protocol) - 11); + int length = strlen(protocol) - 11; +- free(protocol); + obfs = (char*)malloc(length); + memset(protocol, 0x00, length); + memcpy(protocol, text, length); + LOGI("protocol compatible enable, %s", protocol); + free(text); ++ free(protocol); + protocol_compatible = 1; + } + } +@@ -1964,12 +1964,12 @@ + text = (char*)malloc(strlen(obfs) - 11); + memcpy(text, obfs, strlen(obfs) - 11); + int length = strlen(obfs) - 11; +- free(obfs); + obfs = (char*)malloc(length); + memset(obfs, 0x00, length); + memcpy(obfs, text, length); + LOGI("obfs compatible enable, %s", obfs); + free(text); ++ free(obfs); + obfs_compatible = 1; + } + } From 70d02c24cd42f1be7db33ae6256364701ce5afbc Mon Sep 17 00:00:00 2001 From: lededev <30518126+lededev@users.noreply.github.com> Date: Sat, 4 Nov 2023 07:54:40 +0800 Subject: [PATCH 2/4] Update 104-pointer-used-after-free.patch --- .../patches/104-pointer-used-after-free.patch | 40 ++++++------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/shadowsocksr-libev/patches/104-pointer-used-after-free.patch b/shadowsocksr-libev/patches/104-pointer-used-after-free.patch index b1ce790ab..7b12cc6c1 100644 --- a/shadowsocksr-libev/patches/104-pointer-used-after-free.patch +++ b/shadowsocksr-libev/patches/104-pointer-used-after-free.patch @@ -2,30 +2,16 @@ diff -ur a/server/server.c b/server/server.c --- a/server/server.c +++ b/server/server.c @@ -1942,12 +1942,12 @@ - text = (char*)malloc(strlen(protocol) - 11); - memcpy(text, protocol, strlen(protocol) - 11); - int length = strlen(protocol) - 11; -- free(protocol); - obfs = (char*)malloc(length); - memset(protocol, 0x00, length); - memcpy(protocol, text, length); - LOGI("protocol compatible enable, %s", protocol); - free(text); -+ free(protocol); - protocol_compatible = 1; - } - } -@@ -1964,12 +1964,12 @@ - text = (char*)malloc(strlen(obfs) - 11); - memcpy(text, obfs, strlen(obfs) - 11); - int length = strlen(obfs) - 11; -- free(obfs); - obfs = (char*)malloc(length); - memset(obfs, 0x00, length); - memcpy(obfs, text, length); - LOGI("obfs compatible enable, %s", obfs); - free(text); -+ free(obfs); - obfs_compatible = 1; - } - } + text = (char*)malloc(strlen(protocol) - 11); + memcpy(text, protocol, strlen(protocol) - 11); + int length = strlen(protocol) - 11; +- free(protocol); + obfs = (char*)malloc(length); + memset(protocol, 0x00, length); + memcpy(protocol, text, length); + LOGI("protocol compatible enable, %s", protocol); + free(text); ++ free(protocol); + protocol_compatible = 1; + } + } From 079d8c9ebc09ca0bfd42706df9d96d222eaebf63 Mon Sep 17 00:00:00 2001 From: lededev <30518126+lededev@users.noreply.github.com> Date: Sat, 4 Nov 2023 08:05:51 +0800 Subject: [PATCH 3/4] line end CRLF --- .../patches/104-pointer-used-after-free.patch | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/shadowsocksr-libev/patches/104-pointer-used-after-free.patch b/shadowsocksr-libev/patches/104-pointer-used-after-free.patch index 7b12cc6c1..26ad19da4 100644 --- a/shadowsocksr-libev/patches/104-pointer-used-after-free.patch +++ b/shadowsocksr-libev/patches/104-pointer-used-after-free.patch @@ -1,17 +1,17 @@ -diff -ur a/server/server.c b/server/server.c ---- a/server/server.c -+++ b/server/server.c -@@ -1942,12 +1942,12 @@ - text = (char*)malloc(strlen(protocol) - 11); - memcpy(text, protocol, strlen(protocol) - 11); - int length = strlen(protocol) - 11; -- free(protocol); - obfs = (char*)malloc(length); - memset(protocol, 0x00, length); - memcpy(protocol, text, length); - LOGI("protocol compatible enable, %s", protocol); - free(text); -+ free(protocol); - protocol_compatible = 1; - } - } +diff -ur a/server/server.c b/server/server.c +--- a/server/server.c ++++ b/server/server.c +@@ -1942,12 +1942,12 @@ + text = (char*)malloc(strlen(protocol) - 11); + memcpy(text, protocol, strlen(protocol) - 11); + int length = strlen(protocol) - 11; +- free(protocol); + obfs = (char*)malloc(length); + memset(protocol, 0x00, length); + memcpy(protocol, text, length); + LOGI("protocol compatible enable, %s", protocol); + free(text); ++ free(protocol); + protocol_compatible = 1; + } + } \ No newline at end of file From 401e337dadc63716383a46d3414f8f95f46ca6f1 Mon Sep 17 00:00:00 2001 From: lededev <30518126+lededev@users.noreply.github.com> Date: Sat, 4 Nov 2023 08:19:26 +0800 Subject: [PATCH 4/4] Update 104-pointer-used-after-free.patch --- .../patches/104-pointer-used-after-free.patch | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/shadowsocksr-libev/patches/104-pointer-used-after-free.patch b/shadowsocksr-libev/patches/104-pointer-used-after-free.patch index 26ad19da4..d63c0c602 100644 --- a/shadowsocksr-libev/patches/104-pointer-used-after-free.patch +++ b/shadowsocksr-libev/patches/104-pointer-used-after-free.patch @@ -1,7 +1,7 @@ -diff -ur a/server/server.c b/server/server.c ---- a/server/server.c -+++ b/server/server.c -@@ -1942,12 +1942,12 @@ +diff -ur a/server/server.c b/server/server.c +--- a/server/server.c ++++ b/server/server.c +@@ -1942,12 +1942,12 @@ text = (char*)malloc(strlen(protocol) - 11); memcpy(text, protocol, strlen(protocol) - 11); int length = strlen(protocol) - 11; @@ -14,4 +14,4 @@ diff -ur a/server/server.c b/server/server.c + free(protocol); protocol_compatible = 1; } - } \ No newline at end of file + }