1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-03-08 20:58:20 +03:00

Merge pull request #11743 from keszybz/two-memory-fixups

Two fixups for issues found by scanners
This commit is contained in:
Lennart Poettering 2019-02-18 12:09:25 +01:00 committed by GitHub
commit 31ced79065
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 5 deletions

View File

@ -601,10 +601,11 @@ static int base64_append_width(
lines = DIV_ROUND_UP(len, width);
slen = strlen_ptr(sep);
if (lines > (SSIZE_MAX - plen - 1 - slen) / (indent + width + 1))
if (plen >= SSIZE_MAX - 1 - slen ||
lines > (SSIZE_MAX - plen - 1 - slen) / (indent + width + 1))
return -ENOMEM;
t = realloc(*prefix, plen + 1 + slen + (indent + width + 1) * lines);
t = realloc(*prefix, (ssize_t) plen + 1 + slen + (indent + width + 1) * lines);
if (!t)
return -ENOMEM;

View File

@ -880,6 +880,7 @@ fail:
int calendar_spec_from_string(const char *p, CalendarSpec **spec) {
const char *utc;
_cleanup_(calendar_spec_freep) CalendarSpec *c = NULL;
_cleanup_free_ char *p_tmp = NULL;
int r;
assert(p);
@ -894,7 +895,9 @@ int calendar_spec_from_string(const char *p, CalendarSpec **spec) {
utc = endswith_no_case(p, " UTC");
if (utc) {
c->utc = true;
p = strndupa(p, utc - p);
p = p_tmp = strndup(p, utc - p);
if (!p)
return -ENOMEM;
} else {
const char *e = NULL;
int j;
@ -919,7 +922,10 @@ int calendar_spec_from_string(const char *p, CalendarSpec **spec) {
/* Found one of the two timezones specified? */
if (IN_SET(j, 0, 1)) {
p = strndupa(p, e - p - 1);
p = p_tmp = strndup(p, e - p - 1);
if (!p)
return -ENOMEM;
c->dst = j;
} else {
const char *last_space;
@ -930,7 +936,9 @@ int calendar_spec_from_string(const char *p, CalendarSpec **spec) {
if (!c->timezone)
return -ENOMEM;
p = strndupa(p, last_space - p);
p = p_tmp = strndup(p, last_space - p);
if (!p)
return -ENOMEM;
}
}
}

File diff suppressed because one or more lines are too long