Skip to content

Commit

Permalink
check that clipboard message has data before dereferencing pointer in…
Browse files Browse the repository at this point in the history
… order to prevent panics (#10766)
  • Loading branch information
Isaiah Becker-Mayer authored Mar 3, 2022
1 parent 8026e8c commit cc1caaf
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions lib/srv/desktop/rdp/rdpclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,17 @@ func (c *Client) start() {
return
}
case tdp.ClipboardData:
if err := cgoError(C.update_clipboard(
c.rustClient,
(*C.uint8_t)(unsafe.Pointer(&m[0])),
C.uint32_t(len(m)),
)); err != nil {
c.cfg.Log.Warningf("Failed forwarding RDP clipboard data: %v", err)
return
if len(m) > 0 {
if err := cgoError(C.update_clipboard(
c.rustClient,
(*C.uint8_t)(unsafe.Pointer(&m[0])),
C.uint32_t(len(m)),
)); err != nil {
c.cfg.Log.Warningf("Failed forwarding RDP clipboard data: %v", err)
return
}
} else {
c.cfg.Log.Warning("Recieved an empty clipboard message")
}
default:
c.cfg.Log.Warningf("Skipping unimplemented TDP message type %T", msg)
Expand Down

0 comments on commit cc1caaf

Please sign in to comment.