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:
commit
31ced79065
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
10
test/fuzz/fuzz-unit-file/oss-fuzz-13125
Normal file
10
test/fuzz/fuzz-unit-file/oss-fuzz-13125
Normal file
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user