diff options
author | Alice Frosi <afrosi@redhat.com> | 2023-07-14 12:48:37 +0200 |
---|---|---|
committer | Alice Frosi <afrosi@redhat.com> | 2023-07-14 12:48:37 +0200 |
commit | 2878f461e18869d7a63a6994a2e43fce05338c1b (patch) | |
tree | d8915ab47bb10dad06ce3db1559ac7fa4d649ec3 /common | |
parent | 39e878725b2c71d10726c97a69a7e12331c47f24 (diff) | |
download | seitan-2878f461e18869d7a63a6994a2e43fce05338c1b.tar seitan-2878f461e18869d7a63a6994a2e43fce05338c1b.tar.gz seitan-2878f461e18869d7a63a6994a2e43fce05338c1b.tar.bz2 seitan-2878f461e18869d7a63a6994a2e43fce05338c1b.tar.lz seitan-2878f461e18869d7a63a6994a2e43fce05338c1b.tar.xz seitan-2878f461e18869d7a63a6994a2e43fce05338c1b.tar.zst seitan-2878f461e18869d7a63a6994a2e43fce05338c1b.zip |
common, ops: add error print and return if desc is empty
Diffstat (limited to 'common')
-rw-r--r-- | common/gluten.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/common/gluten.h b/common/gluten.h index 83cfbc3..fe62827 100644 --- a/common/gluten.h +++ b/common/gluten.h @@ -341,8 +341,10 @@ static inline const void *gluten_ptr(const struct seccomp_data *s, struct gluten *g, const struct gluten_offset x) { - if (!is_offset_valid(x)) + if (!is_offset_valid(x)) { + err(" offset limits are invalid"); return NULL; + } if (x.type == OFFSET_SECCOMP_DATA && s == NULL) return NULL; @@ -364,6 +366,7 @@ static inline const void *gluten_ptr(const struct seccomp_data *s, static inline bool check_gluten_limits(struct gluten_offset v, size_t size) { struct gluten_offset off = { v.type, v.offset + size }; + if (v.type == OFFSET_SECCOMP_DATA || is_offset_valid(off)) return true; @@ -388,8 +391,10 @@ static inline int gluten_read(const struct seccomp_data *s, struct gluten *g, size_t size) { const void *p = gluten_ptr(s, g, src); + if (p == NULL || !check_gluten_limits(src, size)) return -1; + memcpy(dst, p, size); return 0; |