diff options
author | Alice Frosi <afrosi@redhat.com> | 2023-05-09 16:28:58 +0200 |
---|---|---|
committer | Alice Frosi <afrosi@redhat.com> | 2023-05-10 13:47:04 +0200 |
commit | b2aed1dc699adbac63bd35ffb5b014384a58fb94 (patch) | |
tree | fa0cce450cd76cdce4bd723ec110e4809c4bb888 /operations.c | |
parent | 92afac2a0ca640f19d39da6e7e82e1acb93e2024 (diff) | |
download | seitan-b2aed1dc699adbac63bd35ffb5b014384a58fb94.tar seitan-b2aed1dc699adbac63bd35ffb5b014384a58fb94.tar.gz seitan-b2aed1dc699adbac63bd35ffb5b014384a58fb94.tar.bz2 seitan-b2aed1dc699adbac63bd35ffb5b014384a58fb94.tar.lz seitan-b2aed1dc699adbac63bd35ffb5b014384a58fb94.tar.xz seitan-b2aed1dc699adbac63bd35ffb5b014384a58fb94.tar.zst seitan-b2aed1dc699adbac63bd35ffb5b014384a58fb94.zip |
seitan: add check for limits to op_cmp
Adding the offset limits checks and unit tests.
Diffstat (limited to 'operations.c')
-rw-r--r-- | operations.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/operations.c b/operations.c index af86568..382474c 100644 --- a/operations.c +++ b/operations.c @@ -332,12 +332,19 @@ int op_inject_a(const struct seccomp_notif *req, int notifier, struct gluten *g, int op_cmp(const struct seccomp_notif *req, int notifier, struct gluten *g, struct op_cmp *op) { - int res = memcmp(gluten_ptr(&req->data, g, op->x), - gluten_ptr(&req->data, g, op->y), op->size); + const void *px = gluten_ptr(&req->data, g, op->x); + const void *py = gluten_ptr(&req->data, g, op->y); enum op_cmp_type cmp = op->cmp; + int res; (void)notifier; + if (px == NULL || py == NULL || !check_gluten_limits(op->x, op->size) || + !check_gluten_limits(op->y, op->size)) + return -1; + + res = memcmp(px, py, op->size); + if ((res == 0 && (cmp == CMP_EQ || cmp == CMP_LE || cmp == CMP_GE)) || (res < 0 && (cmp == CMP_LT || cmp == CMP_LE)) || (res > 0 && (cmp == CMP_GT || cmp == CMP_GE)) || |