Skip to content

Commit

Permalink
Silence an UBSAN fuzzing fault
Browse files Browse the repository at this point in the history
  • Loading branch information
uNetworkingAB committed Jan 1, 2020
1 parent 9038988 commit 6fe5ea4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/WebSocketProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,10 @@ static inline size_t formatClosePayload(char *dst, uint16_t code, const char *me
if (code) {
code = cond_byte_swap<uint16_t>(code);
memcpy(dst, &code, 2);
memcpy(dst + 2, message, length);
/* It is invalid to pass nullptr to memcpy, even though length is 0 */
if (message) {
memcpy(dst + 2, message, length);
}
return length + 2;
}
return 0;
Expand Down

0 comments on commit 6fe5ea4

Please sign in to comment.