1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-26 04:17:33 +00:00

journal.cc: Add more overflow checks (#570)

This commit is contained in:
Brenden Matthews 2018-08-06 11:32:04 -04:00 committed by GitHub
parent 58d70d2c25
commit fd4ab7fc07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -88,6 +88,8 @@ void init_journal(const char *type, const char *arg, struct text_object *obj,
CRIT_ERR(obj, free_at_crash,
"invalid arg for %s, type must be 'system' or 'user'", type);
}
} else {
NORM_ERR("You should type a 'user' or 'system' as an argument");
}
} else {
@ -114,7 +116,13 @@ static int print_field(sd_journal *jh, const char *field, char spacer,
*read += length - fieldlen;
out:
if (spacer) p[(*read)++] = spacer;
if (spacer) {
if (p_max_size < *read) {
*read = p_max_size - 1;
} else {
p[(*read)++] = spacer;
}
}
return length ? length - fieldlen : 0;
}