Merge pull request #27719 from mrc0mmand/fuzz-tweaks

fuzz: a couple of fixes for issues found by Nallocfuzz
This commit is contained in:
Mike Yuan
2023-05-21 15:41:15 +08:00
committed by GitHub
4 changed files with 6 additions and 6 deletions

View File

@@ -10,7 +10,6 @@ System and Service Manager
[![CentOS CI - CentOS 8](https://jenkins-systemd.apps.ocp.cloud.ci.centos.org/buildStatus/icon?subject=CentOS%20CI%20-%20CentOS%208&job=upstream-centos8)](https://jenkins-systemd.apps.ocp.cloud.ci.centos.org/job/upstream-centos8/)<br/>
[![CentOS CI - Arch](https://jenkins-systemd.apps.ocp.cloud.ci.centos.org/buildStatus/icon?subject=CentOS%20CI%20-%20Arch&job=upstream-vagrant-archlinux)](https://jenkins-systemd.apps.ocp.cloud.ci.centos.org/job/upstream-vagrant-archlinux/)<br/>
[![CentOS CI - Arch (sanitizers)](https://jenkins-systemd.apps.ocp.cloud.ci.centos.org/buildStatus/icon?subject=CentOS%20CI%20-%20Arch%20(sanitizers)&job=upstream-vagrant-archlinux-sanitizers)](https://jenkins-systemd.apps.ocp.cloud.ci.centos.org/job/upstream-vagrant-archlinux-sanitizers/)<br/>
[![CentOS CI - Rawhide (SELinux)](https://jenkins-systemd.apps.ocp.cloud.ci.centos.org/buildStatus/icon?subject=CentOS%20CI%20-%20Rawhide%20(SELinux)&job=upstream-vagrant-rawhide-selinux)](https://jenkins-systemd.apps.ocp.cloud.ci.centos.org/view/Upstream/job/upstream-vagrant-rawhide-selinux/)<br/>
[![Fossies codespell report](https://fossies.org/linux/test/systemd-main.tar.gz/codespell.svg)](https://fossies.org/linux/test/systemd-main.tar.gz/codespell.html)</br>
[![Weblate](https://translate.fedoraproject.org/widgets/systemd/-/master/svg-badge.svg)](https://translate.fedoraproject.org/engage/systemd/)</br>
[![Coverage Status](https://coveralls.io/repos/github/systemd/systemd/badge.svg?branch=main)](https://coveralls.io/github/systemd/systemd?branch=main)</br>

View File

@@ -15,7 +15,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (!getenv("SYSTEMD_LOG_LEVEL"))
log_set_max_level(LOG_CRIT);
str = memdup_suffix0(data, size);
assert_se(str = memdup_suffix0(data, size));
size_t l1 = strlen(str);
const char* usecs = l1 < size ? str + l1 + 1 : "";

View File

@@ -12,7 +12,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (!getenv("SYSTEMD_LOG_LEVEL"))
log_set_max_level(LOG_CRIT);
str = memdup_suffix0(data, size);
assert_se(str = memdup_suffix0(data, size));
(void) parse_timestamp(str, &usec);
(void) parse_sec(str, &usec);

View File

@@ -1203,11 +1203,12 @@ static sd_event_source *source_new(sd_event *e, bool floating, EventSourceType t
assert(type < _SOURCE_EVENT_SOURCE_TYPE_MAX);
assert(size_table[type] > 0);
/* We use expand_to_usable() here to tell gcc that it should consider this an object of the full
* size, even if we only allocate the initial part we need. */
s = expand_to_usable(malloc0(size_table[type]), sizeof(sd_event_source));
s = malloc0(size_table[type]);
if (!s)
return NULL;
/* We use expand_to_usable() here to tell gcc that it should consider this an object of the full
* size, even if we only allocate the initial part we need. */
s = expand_to_usable(s, sizeof(sd_event_source));
/* Note: we cannot use compound initialization here, because sizeof(sd_event_source) is likely larger
* than what we allocated here. */