diff options
author | Kevin Harwell <kharwell@digium.com> | 2014-06-16 16:22:33 +0000 |
---|---|---|
committer | Kevin Harwell <kharwell@digium.com> | 2014-06-16 16:22:33 +0000 |
commit | bd0aa4fb04afe0d91b5fac2fc697fafd644cc907 (patch) | |
tree | 43dd06d444f6725302ed3333c98a451e9c8e9602 /include | |
parent | a1e0a5e4b07387bcc59afa7c0ab9f960a389ac15 (diff) |
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
Diffstat (limited to 'include')
-rw-r--r-- | include/asterisk/http_websocket.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/include/asterisk/http_websocket.h b/include/asterisk/http_websocket.h index d95e6068e..074ae1202 100644 --- a/include/asterisk/http_websocket.h +++ b/include/asterisk/http_websocket.h @@ -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 |