CBL-Mariner/SPECS/libcap/CVE-2023-2603.patch

27 lines
747 B
Diff

diff --git a/libcap/cap_alloc.c b/libcap/cap_alloc.c
index 6a674f4..667a3ba 100644
--- a/libcap/cap_alloc.c
+++ b/libcap/cap_alloc.c
@@ -96,15 +96,16 @@ char *_libcap_strdup(const char *old)
errno = EINVAL;
return NULL;
}
- len = strlen(old) + 1 + 2*sizeof(__u32);
- if (len < sizeof(struct _cap_alloc_s)) {
- len = sizeof(struct _cap_alloc_s);
- }
- if ((len & 0xffffffff) != len) {
+ len = strlen(old);
+ if ((len & 0x3fffffff) != len) {
_cap_debug("len is too long for libcap to manage");
errno = EINVAL;
return NULL;
}
+ len += 1 + 2*sizeof(__u32);
+ if (len < sizeof(struct _cap_alloc_s)) {
+ len = sizeof(struct _cap_alloc_s);
+ }
raw_data = calloc(1, len);
if (raw_data == NULL) {