Message ID | 20250314131054.24450-3-cgoettsche@seltendoof.de (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [v2,1/4] libselinux: constify global strings | expand |
diff --git a/libselinux/src/label_file.h b/libselinux/src/label_file.h index 470e2385..5fc76b7e 100644 --- a/libselinux/src/label_file.h +++ b/libselinux/src/label_file.h @@ -439,6 +439,12 @@ static inline int compile_regex(struct regex_spec *spec, char *errbuf, size_t er reg_buf = spec->regex_str; /* Anchor the regular expression. */ len = strlen(reg_buf); + if (len >= 4096) { + __pthread_mutex_unlock(&spec->regex_lock); + snprintf(errbuf, errbuf_size, "regex of length %zu too long", len); + errno = EINVAL; + return -1; + } cp = anchored_regex = malloc(len + 3); if (!anchored_regex) { __pthread_mutex_unlock(&spec->regex_lock);