Review Board 1.7.16


Websocket: Add locking around session access and modification

Review Request #3481 - Created April 25, 2014 and submitted

opticron
branches/11
ASTERISK-23605
Reviewers
asterisk-dev
Asterisk
This resolves a race condition where data could be written to a NULL FILE pointer causing a crash as a websocket connection was in the process of shutting down by adding locking to accesses and modifications of the websocket session struct.

 

Changes between revision 3 and 4

1 2 3 4
1 2 3 4

  1. branches/11/res/res_http_websocket.c: Loading...
branches/11/res/res_http_websocket.c
Diff Revision 3 Diff Revision 4
[20] 76 lines
[+20] [+] struct ast_websocket {
77
	size_t payload_len;               /*!< Length of the payload */
77
	size_t payload_len;               /*!< Length of the payload */
78
	char *payload;                    /*!< Pointer to the payload */
78
	char *payload;                    /*!< Pointer to the payload */
79
	size_t reconstruct;               /*!< Number of bytes before a reconstructed payload will be returned and a new one started */
79
	size_t reconstruct;               /*!< Number of bytes before a reconstructed payload will be returned and a new one started */
80
	unsigned int secure:1;            /*!< Bit to indicate that the transport is secure */
80
	unsigned int secure:1;            /*!< Bit to indicate that the transport is secure */
81
	unsigned int closing:1;           /*!< Bit to indicate that the session is in the process of being closed */
81
	unsigned int closing:1;           /*!< Bit to indicate that the session is in the process of being closed */

    
   
82
	unsigned int close_sent:1;        /*!< Bit to indicate that the session close opcode has been sent and no further data will be sent */
82
};
83
};
83

    
   
84

   
84
/*! \brief Structure definition for protocols */
85
/*! \brief Structure definition for protocols */
85
struct websocket_protocol {
86
struct websocket_protocol {
86
	char *name;                      /*!< Name of the protocol */
87
	char *name;                      /*!< Name of the protocol */
[+20] [20] 660 lines
  1. branches/11/res/res_http_websocket.c: Loading...

https://reviewboard.asterisk.org/ runs on a server provided by Digium, Inc. and uses bandwidth donated to the open source Asterisk community by API Digital Communications in Huntsville, AL USA.
Please report problems with this site to asteriskteam@digium.com.