File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,9 @@ pub(crate) const CLASS_IN: u16 = 1;
3232pub ( crate ) const CLASS_MASK : u16 = 0x7FFF ;
3333pub ( crate ) const CLASS_UNIQUE : u16 = 0x8000 ;
3434
35- pub ( crate ) const MAX_MSG_ABSOLUTE : usize = 8966 ;
35+ /// Max size of UDP datagram payload: 9000 bytes - IP header 20 bytes - UDP header 8 bytes.
36+ /// Reference: RFC6762: https://datatracker.ietf.org/doc/html/rfc6762#section-17
37+ pub ( crate ) const MAX_MSG_ABSOLUTE : usize = 8972 ;
3638
3739// Definitions for DNS message header "flags" field
3840//
Original file line number Diff line number Diff line change @@ -1386,6 +1386,13 @@ impl Zeroconf {
13861386 None => return false ,
13871387 } ;
13881388 let mut buf = vec ! [ 0u8 ; MAX_MSG_ABSOLUTE ] ;
1389+
1390+ // Read the next mDNS UDP datagram.
1391+ //
1392+ // If the datagram is larger than `buf`, excess bytes may or may not
1393+ // be truncated by the socket layer depending on the platform's libc.
1394+ // In any case, such large datagram will not be decoded properly and
1395+ // this function should return false but should not crash.
13891396 let sz = match intf_sock. sock . read ( & mut buf) {
13901397 Ok ( sz) => sz,
13911398 Err ( e) => {
You can’t perform that action at this time.
0 commit comments