Skip to content

Commit c3e69cf

Browse files
alexanderstephanGarfield96
authored andcommitted
BUG/MINOR: acl: Add OOM check for calloc() in smp_fetch_acl_parse()
This patch adds a missing out-of-memory (OOM) check after the call to `calloc()` in `smp_fetch_acl_parse()`. If memory allocation fails, an error message is set and the function returns 0, improving robustness in low-memory situations. Co-authored-by: Christian Norbert Menges <christian.norbert.menges@sap.com>
1 parent 22ac1f5 commit c3e69cf

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/acl.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,6 +1351,10 @@ int smp_fetch_acl_parse(struct arg *args, char **err_msg)
13511351
for (i = 0; args[i].type != ARGT_STOP; i++)
13521352
;
13531353
acl_sample = calloc(1, sizeof(struct acl_sample) + sizeof(struct acl_term) * i);
1354+
if (unlikely(!acl_sample)) {
1355+
memprintf(err_msg, "out of memory when parsing ACL expression");
1356+
return 0;
1357+
}
13541358
LIST_INIT(&acl_sample->suite.terms);
13551359
LIST_INIT(&acl_sample->cond.suites);
13561360
LIST_APPEND(&acl_sample->cond.suites, &acl_sample->suite.list);

0 commit comments

Comments
 (0)