diff options
author | Mattias Andrée <m@maandree.se> | 2025-02-20 20:24:28 +0100 |
---|---|---|
committer | Mattias Andrée <m@maandree.se> | 2025-02-20 20:24:28 +0100 |
commit | 4c745dab4c6925fa17714c2214ed5941e5cbf64d (patch) | |
tree | 30129b2838d7a27a7a37fd37f5f95d6b355b7203 /libterminput_unmarshal_text__.c | |
parent | Add state marshalling and unmarshalling functions (diff) | |
download | libterminput-4c745dab4c6925fa17714c2214ed5941e5cbf64d.tar.gz libterminput-4c745dab4c6925fa17714c2214ed5941e5cbf64d.tar.bz2 libterminput-4c745dab4c6925fa17714c2214ed5941e5cbf64d.tar.xz |
Validate unmarshalled state + add man pages for (un)marshal functions
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to '')
-rw-r--r-- | libterminput_unmarshal_text__.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/libterminput_unmarshal_text__.c b/libterminput_unmarshal_text__.c index 4843db4..bb25fe4 100644 --- a/libterminput_unmarshal_text__.c +++ b/libterminput_unmarshal_text__.c @@ -3,11 +3,14 @@ int -libterminput_unmarshal_text__(struct libterminput_unmarshaller *how, struct libterminput_text *what) +libterminput_unmarshal_text__(struct libterminput_unmarshaller *how, struct libterminput_text *what) /* TODO test */ { what->type = LIBTERMINPUT_TEXT; - if (how->load(how, &what->nbytes, sizeof(what->nbytes)) || - how->load(how, what->bytes, sizeof(what->nbytes))) + if (how->load(how, &what->nbytes, sizeof(what->nbytes))) return -1; - return 0; + if (what->nbytes > sizeof(what->bytes)) { + errno = EINVAL; + return -1; + } + return how->load(how, what->bytes, what->nbytes); } |