Skip to content

Commit 5e46735

Browse files
committed
Merge branch 'master' of github.com:sctplab/usrsctp
2 parents 0c9e649 + d520eaf commit 5e46735

File tree

123 files changed

+155
-155
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+155
-155
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,9 @@ elseif (CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID MATCHES "Appl
259259
endif ()
260260

261261
if (sctp_build_fuzzer)
262+
set(CMAKE_BUILD_TYPE "DEBUG")
262263
add_definitions(-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
263-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=fuzzer-no-link")
264+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O1 -fsanitize=fuzzer-no-link")
264265
endif ()
265266
endif ()
266267

fuzzer/CORPUS_CONNECT/addip-000000

45 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/addip-000001

45 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/addip-000002

73 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/addip-000003

73 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/addip-000004

49 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/addip-000005

45 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/addip-000006

49 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/addip-000007

45 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/addip-000008

73 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/addip-000009

73 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/addip-000010

49 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/addip-000011

49 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/dummy-01

73 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/rtcweb-000000

0 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/rtcweb-000001

0 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/rtcweb-000002

0 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/rtcweb-000003

10 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/rtcweb-000004

0 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/rtcweb-000005

0 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/rtcweb-000006

0 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/rtcweb-000007

0 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/rtcweb-000008

0 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/rtcweb-000009

0 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/rtcweb-000010

0 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/rtcweb-000011

0 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/rtcweb-000012

0 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/rtcweb-000013

0 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/rtcweb-000014

0 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/rtcweb-000015

0 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/rtcweb-000016

-16 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/rtcweb-000017

-26 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/rtcweb-000018

-32 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/rtcweb-000019

-17 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/rtcweb-000020

-33 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/rtcweb-000021

-17 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/rtcweb-000022

-25 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/rtcweb-000023

-17 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/rtcweb-000024

-25 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/rtcweb-000025

-17 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/rtcweb-000026

-15 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/rtcweb-000027

-5 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/rtcweb-000028

-15 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000000

-20 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000001

-76 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000002

-48 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000004

172 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000005

172 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000006

-28 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000007

-1 KB
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000008

-1.01 KB
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000009

-1 KB
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000010

-1.01 KB
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000011

-1.02 KB
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000012

-45 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000013

-17 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000014

-17 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000015

-17 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000016

-17 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000017

-9 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000020

-137 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000021

-529 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000022

-401 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000024

-45 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000025

-45 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000026

-45 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000027

-1.12 KB
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000028

-1.33 KB
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000029

-929 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000030

-45 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000031

-1.33 KB
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000032

-17 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000033

-929 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000034

-17 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000035

-17 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000036

-17 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000037

-9 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000038

-15 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000039

-5 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000040

-137 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000041

-529 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000042

-401 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000043

-15 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000044

-45 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000045

-45 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000046

-45 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000047

-1.18 KB
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000048

-1.35 KB
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000049

-45 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000050

-1 KB
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000051

-1.18 KB
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000052

-17 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000053

-1.18 KB
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000054

-17 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000055

-17 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000056

-9 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000057

-15 Bytes
Binary file not shown.

fuzzer/CORPUS_CONNECT/tsctp-000058

-5 Bytes
Binary file not shown.
109 Bytes
Binary file not shown.
429 Bytes
Binary file not shown.
337 Bytes
Binary file not shown.
221 Bytes
Binary file not shown.
221 Bytes
Binary file not shown.
17 Bytes
Binary file not shown.
17 Bytes
Binary file not shown.
9 Bytes
Binary file not shown.

fuzzer/build-fuzzer.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pwd
4141
find . -iwholename '*cmake*' -not -name CMakeLists.txt -delete
4242

4343
# Build with ASAN / MSAN
44-
cmake -Dsctp_build_fuzzer=1 -Dsctp_build_programs=0 -Dsctp_invariants=1 -Dsctp_sanitizer_address=1 -DCMAKE_LINKER="$CC" -DCMAKE_C_COMPILER="$CC" -DCMAKE_BUILD_TYPE=Debug .
45-
#cmake -Dsctp_build_fuzzer=1 -Dsctp_build_programs=0 -Dsctp_invariants=1 -Dsctp_sanitizer_memory=1 -DCMAKE_LINKER="$CC" -DCMAKE_C_COMPILER="$CC" -DCMAKE_BUILD_TYPE=RelWithDebInfo .
44+
cmake -Dsctp_build_fuzzer=1 -Dsctp_build_programs=0 -Dsctp_invariants=1 -Dsctp_sanitizer_address=1 -DCMAKE_LINKER="$CC" -DCMAKE_C_COMPILER="$CC" .
45+
#cmake -Dsctp_build_fuzzer=1 -Dsctp_build_programs=0 -Dsctp_invariants=1 -Dsctp_sanitizer_memory=1 -DCMAKE_LINKER="$CC" -DCMAKE_C_COMPILER="$CC" .
4646

4747
make -j"$NPROC"

fuzzer/check-input.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ echo "########## Beginning Fuzzer Chain"
1818
echo ""
1919

2020
set +e
21-
./fuzzer_connect_multi_verbose -timeout=30 $1 > $1.log 2>&1
21+
./fuzzer_connect_multi_verbose -timeout=10 $1 > $1.log 2>&1
2222
FUZZER_RETVAL=$?
2323
set -e
2424

fuzzer/crashtest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import re
66

77
reportdir = "reports/"
8-
fuzzer = "./fuzzer_connect_multi"
98

109
class bcolors:
1110
HEADER = '\033[95m'

fuzzer/fuzzer_connect.c

Lines changed: 96 additions & 126 deletions
Large diffs are not rendered by default.

fuzzer/fuzzer_connect_multi.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
export ASAN_OPTIONS=abort_on_error=1:disable_core=0:unmap_shadow_on_exit=1:disable_coredump=0:detect_leaks=1
3+
#export ASAN_OPTIONS=abort_on_error=1:disable_core=0:unmap_shadow_on_exit=1:disable_coredump=0:detect_leaks=1
44
ulimit -c unlimited
55
mkdir -p CORPUS_CONNECT
66

@@ -19,4 +19,4 @@ fi
1919
echo "$NPROC"
2020

2121

22-
./fuzzer_connect_multi -jobs=64 -timeout=10 -max_len=32000 CORPUS_CONNECT
22+
./fuzzer_connect_multi -jobs=64 -timeout=10 -max_len=32000 -use_value_profile=1 CORPUS_CONNECT

programs/programs_helper.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,24 @@ void
5252
debug_printf_stack(const char *format, ...)
5353
{
5454
va_list ap;
55+
char charbuf[1024];
56+
static struct timeval time_main;
57+
struct timeval time_now;
58+
struct timeval time_delta;
59+
60+
if (time_main.tv_sec == 0 && time_main.tv_usec == 0) {
61+
gettimeofday(&time_main, NULL);
62+
}
63+
64+
gettimeofday(&time_now, NULL);
65+
timersub(&time_now, &time_main, &time_delta);
5566

5667
va_start(ap, format);
57-
vprintf(format, ap);
68+
//vfprintf(stderr, format, ap);
69+
vsnprintf(charbuf, 1024, format, ap);
5870
va_end(ap);
71+
72+
fprintf(stderr, "[S][%u.%03u] %s", (unsigned int) time_delta.tv_sec, (unsigned int) time_delta.tv_usec / 1000, charbuf);
5973
}
6074

6175
static void

usrsctplib/CMakeLists.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ set(includedir ${prefix}/include/usrsctp)
4343
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR})
4444
set(CMAKE_MACOSX_RPATH 1)
4545

46+
include(CheckCCompilerFlag)
47+
4648
add_definitions(-D__Userspace__)
4749
add_definitions(-D__Userspace_os_${CMAKE_SYSTEM_NAME})
4850
add_definitions(-DSCTP_SIMPLE_ALLOCATOR)
@@ -53,11 +55,16 @@ add_definitions(-DSCTP_PROCESS_LEVEL_LOCKS)
5355
# OS DEPENDENT
5456
#################################################
5557

56-
check_c_compiler_flag(-Wno-address-of-packed-member has_wno_address_of_packet_member)
57-
if (has_wno_address_of_packet_member)
58+
check_c_compiler_flag(-Wno-address-of-packed-member has_wno_address_of_packed_member)
59+
if (has_wno_address_of_packed_member)
5860
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-address-of-packed-member")
5961
endif ()
6062

63+
check_c_compiler_flag(-Wno-deprecated-declarations has_wno_deprecated_declarations)
64+
if (has_wno_deprecated_declarations)
65+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations")
66+
endif ()
67+
6168
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
6269
add_definitions(-D_GNU_SOURCE)
6370
endif ()
@@ -69,7 +76,6 @@ endif ()
6976
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
7077
add_definitions(-U__APPLE__)
7178
add_definitions(-D__APPLE_USE_RFC_2292)
72-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations")
7379
endif ()
7480

7581
if (CMAKE_SYSTEM_NAME MATCHES "DragonFly")

usrsctplib/netinet/sctp_auth.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,6 +1650,11 @@ sctp_handle_auth(struct sctp_tcb *stcb, struct sctp_auth_chunk *auth,
16501650
"SCTP AUTH Chunk: shared key %u, HMAC id %u\n",
16511651
shared_key_id, hmac_id);
16521652

1653+
#if defined(__Userspace__)
1654+
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
1655+
return (0);
1656+
#endif
1657+
#endif
16531658
/* is the indicated HMAC supported? */
16541659
if (!sctp_auth_is_supported_hmac(stcb->asoc.local_hmacs, hmac_id)) {
16551660
struct mbuf *op_err;
@@ -1730,11 +1735,6 @@ sctp_handle_auth(struct sctp_tcb *stcb, struct sctp_auth_chunk *auth,
17301735
(void)sctp_compute_hmac_m(hmac_id, stcb->asoc.authinfo.recv_key,
17311736
m, offset, computed_digest);
17321737

1733-
#if defined(__Userspace__)
1734-
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
1735-
return (0);
1736-
#endif
1737-
#endif
17381738
/* compare the computed digest with the one in the AUTH chunk */
17391739
if (timingsafe_bcmp(digest, computed_digest, digestlen) != 0) {
17401740
SCTP_STAT_INCR(sctps_recvauthfailed);

usrsctplib/netinet/sctp_bsd_addr.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ sctp_startup_iterator(void)
203203
#elif defined(__Userspace__)
204204
if (sctp_userspace_thread_create(&sctp_it_ctl.thread_proc, &sctp_iterator_thread)) {
205205
SCTP_PRINTF("ERROR: Creating sctp_iterator_thread failed.\n");
206+
} else {
207+
SCTP_BASE_VAR(iterator_thread_started) = 1;
206208
}
207209
#endif
208210
}

usrsctplib/netinet/sctp_callout.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ sctp_start_timer(void)
227227
rc = sctp_userspace_thread_create(&SCTP_BASE_VAR(timer_thread), user_sctp_timer_iterate);
228228
if (rc) {
229229
SCTP_PRINTF("ERROR; return code from sctp_thread_create() is %d\n", rc);
230+
} else {
231+
SCTP_BASE_VAR(timer_thread_started) = 1;
230232
}
231233
}
232234

usrsctplib/netinet/sctp_constants.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
#ifdef __FreeBSD__
3636
#include <sys/cdefs.h>
37-
__FBSDID("$FreeBSD: head/sys/netinet/sctp_constants.h 357500 2020-02-04 12:34:16Z tuexen $");
37+
__FBSDID("$FreeBSD: head/sys/netinet/sctp_constants.h 358169 2020-02-20 15:37:44Z tuexen $");
3838
#endif
3939

4040
#ifndef _NETINET_SCTP_CONSTANTS_H_
@@ -551,14 +551,13 @@ extern void getwintimeofday(struct timeval *tv);
551551
#define SCTP_TIMER_TYPE_ASCONF 10
552552
#define SCTP_TIMER_TYPE_SHUTDOWNGUARD 11
553553
#define SCTP_TIMER_TYPE_AUTOCLOSE 12
554-
#define SCTP_TIMER_TYPE_EVENTWAKE 13
555-
#define SCTP_TIMER_TYPE_STRRESET 14
556-
#define SCTP_TIMER_TYPE_INPKILL 15
557-
#define SCTP_TIMER_TYPE_ASOCKILL 16
558-
#define SCTP_TIMER_TYPE_ADDR_WQ 17
559-
#define SCTP_TIMER_TYPE_PRIM_DELETED 18
554+
#define SCTP_TIMER_TYPE_STRRESET 13
555+
#define SCTP_TIMER_TYPE_INPKILL 14
556+
#define SCTP_TIMER_TYPE_ASOCKILL 15
557+
#define SCTP_TIMER_TYPE_ADDR_WQ 16
558+
#define SCTP_TIMER_TYPE_PRIM_DELETED 17
560559
/* add new timers here - and increment LAST */
561-
#define SCTP_TIMER_TYPE_LAST 19
560+
#define SCTP_TIMER_TYPE_LAST 18
562561

563562
#define SCTP_IS_TIMER_TYPE_VALID(t) (((t) > SCTP_TIMER_TYPE_NONE) && \
564563
((t) < SCTP_TIMER_TYPE_LAST))

usrsctplib/netinet/sctp_pcb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6871,7 +6871,7 @@ sctp_pcb_finish(void)
68716871
}
68726872
#endif
68736873
#if defined(__Userspace__)
6874-
if (sctp_it_ctl.thread_proc) {
6874+
if (SCTP_BASE_VAR(iterator_thread_started)) {
68756875
#if defined(__Userspace_os_Windows)
68766876
WaitForSingleObject(sctp_it_ctl.thread_proc, INFINITE);
68776877
CloseHandle(sctp_it_ctl.thread_proc);

usrsctplib/netinet/sctp_pcb.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,8 @@ struct sctp_base_info {
315315
userland_mutex_t timer_mtx;
316316
userland_thread_t timer_thread;
317317
int timer_thread_should_exit;
318+
int iterator_thread_started;
319+
int timer_thread_started;
318320
#if !defined(__Userspace_os_Windows)
319321
pthread_mutexattr_t mtx_attr;
320322
#if defined(INET) || defined(INET6)

usrsctplib/netinet/sctp_usrreq.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,14 @@ sctp_init(void)
161161
SCTP_BASE_VAR(conn_output) = conn_output;
162162
SCTP_BASE_VAR(debug_printf) = debug_printf;
163163
SCTP_BASE_VAR(crc32c_offloaded) = 0;
164+
SCTP_BASE_VAR(iterator_thread_started) = 0;
165+
SCTP_BASE_VAR(timer_thread_started) = 0;
164166
#endif
165167
#if defined(__Userspace__)
166168
sctp_pcb_init(start_threads);
167-
if (start_threads)
169+
if (start_threads) {
168170
sctp_start_timer();
171+
}
169172
#else
170173
sctp_pcb_init();
171174
#endif
@@ -252,12 +255,14 @@ sctp_finish(void)
252255
}
253256
#endif
254257
atomic_cmpset_int(&SCTP_BASE_VAR(timer_thread_should_exit), 0, 1);
258+
if (SCTP_BASE_VAR(timer_thread_started)) {
255259
#if defined(__Userspace_os_Windows)
256-
WaitForSingleObject(SCTP_BASE_VAR(timer_thread), INFINITE);
257-
CloseHandle(SCTP_BASE_VAR(timer_thread));
260+
WaitForSingleObject(SCTP_BASE_VAR(timer_thread), INFINITE);
261+
CloseHandle(SCTP_BASE_VAR(timer_thread));
258262
#else
259-
pthread_join(SCTP_BASE_VAR(timer_thread), NULL);
263+
pthread_join(SCTP_BASE_VAR(timer_thread), NULL);
260264
#endif
265+
}
261266
#endif
262267
sctp_pcb_finish();
263268
#if defined(__Windows__)

0 commit comments

Comments
 (0)