mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
introduce-LWS_WRITE_CLIENT_IGNORE_XOR_MASK.patch
Signed-off-by: Andy Green <andy@warmcat.com>
This commit is contained in:
parent
42f6914d69
commit
bd96d8092e
2 changed files with 27 additions and 11 deletions
|
@ -47,7 +47,15 @@ enum libwebsocket_write_protocol {
|
|||
LWS_WRITE_PING,
|
||||
LWS_WRITE_PONG,
|
||||
|
||||
LWS_WRITE_NO_FIN = 0x40
|
||||
/* flags */
|
||||
|
||||
LWS_WRITE_NO_FIN = 0x40,
|
||||
/*
|
||||
* client packet payload goes out on wire unmunged
|
||||
* only useful for security tests since normal servers cannot
|
||||
* decode the content if used
|
||||
*/
|
||||
LWS_WRITE_CLIENT_IGNORE_XOR_MASK = 0x80
|
||||
};
|
||||
|
||||
struct libwebsocket;
|
||||
|
|
|
@ -1131,19 +1131,27 @@ int libwebsocket_write(struct libwebsocket *wsi, unsigned char *buf,
|
|||
|
||||
if (wsi->client_mode && wsi->ietf_spec_revision == 4) {
|
||||
|
||||
if (libwebsocket_04_frame_mask_generate(wsi)) {
|
||||
fprintf(stderr, "libwebsocket_write: "
|
||||
"frame mask generation failed\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* use the XOR masking against everything we send
|
||||
* past the frame nonce
|
||||
* this is only useful for security tests where it's required
|
||||
* to control the raw packet payload content
|
||||
*/
|
||||
|
||||
for (n = 0; n < (len + pre + post); n++)
|
||||
buf[n - pre] = xor_mask(wsi, buf[n - pre]);
|
||||
if (!(protocol & LWS_WRITE_CLIENT_IGNORE_XOR_MASK)) {
|
||||
|
||||
if (libwebsocket_04_frame_mask_generate(wsi)) {
|
||||
fprintf(stderr, "libwebsocket_write: "
|
||||
"frame mask generation failed\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* use the XOR masking against everything we send
|
||||
* past the frame nonce
|
||||
*/
|
||||
|
||||
for (n = 0; n < (len + pre + post); n++)
|
||||
buf[n - pre] = xor_mask(wsi, buf[n - pre]);
|
||||
}
|
||||
|
||||
/* make space for the frame nonce in clear */
|
||||
pre += 4;
|
||||
|
|
Loading…
Add table
Reference in a new issue