mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-04 20:25:29 +00:00
res_http_websocket: read/write string fixup
There was a problem when reading a string from the websocket. It assumed the received data had a null terminator and tried to write the data to an ast_str. This of course could/would read past the end of the given buffer while writing the data to the internal buffer of ast_str. Modified the the code to correctly place a null terminator on the result string. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@416394 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -156,6 +156,8 @@ AST_OPTIONAL_API(int, ast_websocket_read, (struct ast_websocket *session, char *
|
||||
/*!
|
||||
* \brief Read a WebSocket frame containing string data.
|
||||
*
|
||||
* \note The caller is responsible for freeing the output "buf".
|
||||
*
|
||||
* \param ws pointer to the websocket
|
||||
* \param buf string buffer to populate with data read from socket
|
||||
* \retval -1 on error
|
||||
@@ -164,7 +166,7 @@ AST_OPTIONAL_API(int, ast_websocket_read, (struct ast_websocket *session, char *
|
||||
* \note Once an AST_WEBSOCKET_OPCODE_CLOSE opcode is received the socket will be closed
|
||||
*/
|
||||
AST_OPTIONAL_API(int, ast_websocket_read_string,
|
||||
(struct ast_websocket *ws, struct ast_str **buf),
|
||||
(struct ast_websocket *ws, char **buf),
|
||||
{ errno = ENOSYS; return -1;});
|
||||
|
||||
/*!
|
||||
@@ -189,7 +191,7 @@ AST_OPTIONAL_API(int, ast_websocket_write, (struct ast_websocket *session, enum
|
||||
* \retval -1 if error occurred
|
||||
*/
|
||||
AST_OPTIONAL_API(int, ast_websocket_write_string,
|
||||
(struct ast_websocket *ws, const struct ast_str *buf),
|
||||
(struct ast_websocket *ws, const char *buf),
|
||||
{ errno = ENOSYS; return -1;});
|
||||
/*!
|
||||
* \brief Close a WebSocket session by sending a message with the CLOSE opcode and an optional code
|
||||
|
Reference in New Issue
Block a user