@@ -43,6 +43,12 @@
|
||||
#define MIN_YEAR 1970
|
||||
#define MAX_YEAR 2199
|
||||
|
||||
/* An arbitrary limit on the length of the chains of components. We don't want to
|
||||
* build a very long linked list, which would be slow to iterate over and might cause
|
||||
* our stack to overflow. It's unlikely that legitimate uses require more than a few
|
||||
* linked compenents anyway. */
|
||||
#define CALENDARSPEC_COMPONENTS_MAX 240
|
||||
|
||||
static void free_chain(CalendarComponent *c) {
|
||||
CalendarComponent *n;
|
||||
|
||||
@@ -618,15 +624,16 @@ static int calendarspec_from_time_t(CalendarSpec *c, time_t time) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int prepend_component(const char **p, bool usec, CalendarComponent **c) {
|
||||
static int prepend_component(const char **p, bool usec, unsigned nesting, CalendarComponent **c) {
|
||||
int r, start, stop = -1, repeat = 0;
|
||||
CalendarComponent *cc;
|
||||
const char *e;
|
||||
const char *e = *p;
|
||||
|
||||
assert(p);
|
||||
assert(c);
|
||||
|
||||
e = *p;
|
||||
if (nesting > CALENDARSPEC_COMPONENTS_MAX)
|
||||
return -ENOBUFS;
|
||||
|
||||
r = parse_component_decimal(&e, usec, &start);
|
||||
if (r < 0)
|
||||
@@ -668,7 +675,7 @@ static int prepend_component(const char **p, bool usec, CalendarComponent **c) {
|
||||
|
||||
if (*e ==',') {
|
||||
*p += 1;
|
||||
return prepend_component(p, usec, c);
|
||||
return prepend_component(p, usec, nesting + 1, c);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -697,7 +704,7 @@ static int parse_chain(const char **p, bool usec, CalendarComponent **c) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = prepend_component(&t, usec, &cc);
|
||||
r = prepend_component(&t, usec, 0, &cc);
|
||||
if (r < 0) {
|
||||
free_chain(cc);
|
||||
return r;
|
||||
|
||||
@@ -1977,6 +1977,14 @@ int cg_slice_to_path(const char *unit, char **ret) {
|
||||
_cleanup_free_ char *escaped = NULL;
|
||||
char n[dash - p + sizeof(".slice")];
|
||||
|
||||
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
||||
/* msan doesn't instrument stpncpy, so it thinks
|
||||
* n is later used unitialized:
|
||||
* https://github.com/google/sanitizers/issues/926
|
||||
*/
|
||||
zero(n);
|
||||
#endif
|
||||
|
||||
/* Don't allow trailing or double dashes */
|
||||
if (IN_SET(dash[1], 0, '-'))
|
||||
return -EINVAL;
|
||||
@@ -2475,7 +2483,7 @@ static int cg_unified_update(void) {
|
||||
return 0;
|
||||
|
||||
if (statfs("/sys/fs/cgroup/", &fs) < 0)
|
||||
return log_debug_errno(errno, "statfs(\"/sys/fs/cgroup/\" failed: %m");
|
||||
return log_debug_errno(errno, "statfs(\"/sys/fs/cgroup/\") failed: %m");
|
||||
|
||||
if (F_TYPE_EQUAL(fs.f_type, CGROUP2_SUPER_MAGIC)) {
|
||||
log_debug("Found cgroup2 on /sys/fs/cgroup/, full unified hierarchy");
|
||||
|
||||
+5
-4
@@ -10,12 +10,13 @@
|
||||
/*
|
||||
* Gives us 8 prio classes with 13-bits of data for each class
|
||||
*/
|
||||
#define IOPRIO_BITS (16)
|
||||
#define IOPRIO_CLASS_SHIFT (13)
|
||||
#define IOPRIO_PRIO_MASK ((1UL << IOPRIO_CLASS_SHIFT) - 1)
|
||||
#define IOPRIO_BITS 16
|
||||
#define IOPRIO_N_CLASSES 8
|
||||
#define IOPRIO_CLASS_SHIFT 13
|
||||
#define IOPRIO_PRIO_DATA_MASK ((1UL << IOPRIO_CLASS_SHIFT) - 1)
|
||||
|
||||
#define IOPRIO_PRIO_CLASS(mask) ((mask) >> IOPRIO_CLASS_SHIFT)
|
||||
#define IOPRIO_PRIO_DATA(mask) ((mask) & IOPRIO_PRIO_MASK)
|
||||
#define IOPRIO_PRIO_DATA(mask) ((mask) & IOPRIO_PRIO_DATA_MASK)
|
||||
#define IOPRIO_PRIO_VALUE(class, data) (((class) << IOPRIO_CLASS_SHIFT) | data)
|
||||
|
||||
#define ioprio_valid(mask) (IOPRIO_PRIO_CLASS((mask)) != IOPRIO_CLASS_NONE)
|
||||
|
||||
@@ -1466,7 +1466,7 @@ static const char *const ioprio_class_table[] = {
|
||||
[IOPRIO_CLASS_IDLE] = "idle"
|
||||
};
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(ioprio_class, int, INT_MAX);
|
||||
DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(ioprio_class, int, IOPRIO_N_CLASSES);
|
||||
|
||||
static const char *const sigchld_code_table[] = {
|
||||
[CLD_EXITED] = "exited",
|
||||
|
||||
Reference in New Issue
Block a user