diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 44c8037ba867ad1f1011a098f4e90caf4624b5ca..67c2a1c7cd1f74c8f570af924bc5f815e249c6c4 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -2635,7 +2635,7 @@ static void sip_websocket_callback(struct ast_websocket *session, struct ast_var if (opcode == AST_WEBSOCKET_OPCODE_TEXT || opcode == AST_WEBSOCKET_OPCODE_BINARY) { struct sip_request req = { 0, }; - if (!(req.data = ast_str_create(payload_len))) { + if (!(req.data = ast_str_create(payload_len + 1))) { goto end; } diff --git a/main/utils.c b/main/utils.c index 1ea8371097942bb0eae9ca61e3be73091e24bd30..24a8326a80a229af690e92c1b926efef11009cc7 100644 --- a/main/utils.c +++ b/main/utils.c @@ -1487,9 +1487,6 @@ int ast_remaining_ms(struct timeval start, int max_ms) #undef ONE_MILLION -/*! \brief glibc puts a lock inside random(3), so that the results are thread-safe. - * BSD libc (and others) do not. */ - #ifndef linux AST_MUTEX_DEFINE_STATIC(randomlock); #endif @@ -1508,6 +1505,13 @@ long int ast_random(void) } } #endif + /* XXX - Thread safety really depends on the libc, not the OS. + * + * But... popular Linux libc's (uClibc, glibc, eglibc), all have a + * somewhat thread safe random(3) (results are random, but not + * reproducible). The libc's for other systems (BSD, et al.), not so + * much. + */ #ifdef linux res = random(); #else