Ensure correct message length while deserializing
netlink/data.scm
20 | 20 | #:use-module (srfi srfi-9) | |
21 | 21 | #:export (make-nl-data | |
22 | 22 | nl-data-data nl-data-size-proc nl-data-serialize-proc | |
23 | - | data-size | |
23 | + | data-size ensure-data-size | |
24 | 24 | serialize deserialize | |
25 | 25 | get-current-deserialize get-next-deserialize | |
26 | 26 | define-data-type)) | |
… | |||
38 | 38 | (define (serialize data pos bv) | |
39 | 39 | ((nl-data-serialize-proc data) (nl-data-data data) pos bv)) | |
40 | 40 | ||
41 | + | (define (ensure-data-size data size) | |
42 | + | (make-nl-data | |
43 | + | (nl-data-data data) | |
44 | + | (const size) | |
45 | + | (nl-data-serialize-proc data))) | |
46 | + | ||
41 | 47 | (define (get-next-deserialize decoder current-type target-type) | |
42 | 48 | (match (assoc-ref decoder current-type) | |
43 | 49 | ((_ . type-alist) |
netlink/message.scm
64 | 64 | (bytevector-u32-ref bv (+ pos 8) (native-endianness)) | |
65 | 65 | (bytevector-u32-ref bv (+ pos 12) (native-endianness)) | |
66 | 66 | (if (< (data-size data) (- len 16)) | |
67 | - | (make-nl-data #f (const (- len 16)) (const (make-bytevector 0))) | |
67 | + | (ensure-data-size data (- len 16)) | |
68 | 68 | data))))) | |
69 | 69 | ||
70 | 70 | (define (deserialize-message-header decoder bv pos) |
netlink/standard.scm
43 | 43 | (define (deserialize-error-message decoder bv pos) | |
44 | 44 | (make-error-message | |
45 | 45 | (bytevector-s32-ref bv pos (native-endianness)) | |
46 | - | (deserialize 'message-hdr decoder (pk 'error-mrg bv) (+ pos 4)))) | |
46 | + | (deserialize 'message-hdr decoder bv (+ pos 4)))) | |
47 | 47 | ||
48 | 48 | (define no-data | |
49 | 49 | (make-nl-data |