Fix decoding messages going too far.
netlink/message.scm
52 | 52 | (define (deserialize-message decoder bv pos) | |
53 | 53 | (let* ((len (bytevector-u32-ref bv pos (native-endianness))) | |
54 | 54 | (type (bytevector-u16-ref bv (+ pos 4) (native-endianness))) | |
55 | + | (data (make-bytevector len)) | |
55 | 56 | (deserialize (get-next-deserialize decoder 'message type))) | |
56 | - | (make-message | |
57 | - | type | |
58 | - | (bytevector-u16-ref bv (+ pos 6) (native-endianness)) | |
59 | - | (bytevector-u32-ref bv (+ pos 8) (native-endianness)) | |
60 | - | (bytevector-u32-ref bv (+ pos 12) (native-endianness)) | |
61 | - | (deserialize decoder bv (+ pos 16))))) | |
57 | + | (bytevector-copy! bv pos data 0 len) | |
58 | + | (let ((data (deserialize decoder data 16))) | |
59 | + | (make-message | |
60 | + | type | |
61 | + | (bytevector-u16-ref bv (+ pos 6) (native-endianness)) | |
62 | + | (bytevector-u32-ref bv (+ pos 8) (native-endianness)) | |
63 | + | (bytevector-u32-ref bv (+ pos 12) (native-endianness)) | |
64 | + | (if (< (data-size data) (- len 16)) | |
65 | + | (make-nl-data #f (const (- len 16)) (const (make-bytevector 0))) | |
66 | + | data))))) |