@@ -256,6 +256,9 @@ impl ProtocolHandler for X11ProtocolHandler {
256
256
}
257
257
} else if Some ( buf[ 0 ] ) == this. protocol_handler . dri3_ext_opcode {
258
258
if buf[ 1 ] == DRI3_OPCODE_VERSION {
259
+ if buf. len ( ) < 8 {
260
+ return Ok ( StreamSendResult :: WantMore ) ;
261
+ }
259
262
buf[ 8 ] = buf[ 8 ] . min ( 3 ) ;
260
263
} else if buf[ 1 ] == DRI3_OPCODE_OPEN {
261
264
buf[ 0 ] = X11_OPCODE_NOP ;
@@ -280,6 +283,9 @@ impl ProtocolHandler for X11ProtocolHandler {
280
283
resources. push ( res) ;
281
284
finalizers. push ( X11ResourceFinalizer :: Gem ( finalizer) ) ;
282
285
} else if buf[ 1 ] == DRI3_OPCODE_FENCE_FROM_FD {
286
+ if buf. len ( ) < 12 {
287
+ return Ok ( StreamSendResult :: WantMore ) ;
288
+ }
283
289
let xid = u32:: from_ne_bytes ( buf[ 8 ..12 ] . try_into ( ) . unwrap ( ) ) ;
284
290
let fd = this. request_fds . remove ( 0 ) ;
285
291
let filename = readlink ( format ! ( "/proc/self/fd/{}" , fd. as_raw_fd( ) ) . as_str ( ) ) ?;
@@ -288,6 +294,9 @@ impl ProtocolHandler for X11ProtocolHandler {
288
294
let res = Self :: create_cross_vm_futex ( this, fd, xid, creds. pid ( ) , filename) ?;
289
295
resources. push ( res) ;
290
296
} else if buf[ 1 ] == DRI3_OPCODE_PIXMAP_FROM_BUFFERS {
297
+ if buf. len ( ) < 12 {
298
+ return Ok ( StreamSendResult :: WantMore ) ;
299
+ }
291
300
let num_bufs = buf[ 12 ] as usize ;
292
301
for fd in this. request_fds . drain ( ..num_bufs) . collect :: < Vec < _ > > ( ) {
293
302
let ( res, finalizer) = this. vgpu_id_from_prime ( fd) ?;
@@ -297,6 +306,9 @@ impl ProtocolHandler for X11ProtocolHandler {
297
306
}
298
307
} else if Some ( buf[ 0 ] ) == this. protocol_handler . sync_ext_opcode {
299
308
if buf[ 1 ] == SYNC_OPCODE_DESTROY_FENCE {
309
+ if buf. len ( ) < 8 {
310
+ return Ok ( StreamSendResult :: WantMore ) ;
311
+ }
300
312
let xid = u32:: from_ne_bytes ( buf[ 4 ..8 ] . try_into ( ) . unwrap ( ) ) ;
301
313
finalizers. push ( X11ResourceFinalizer :: Futex ( xid) ) ;
302
314
}
0 commit comments