Skip to content

Low: libcrmcommon: Ignore empty time spec#4075

Open
nrwahl2 wants to merge 2 commits intoClusterLabs:mainfrom
nrwahl2:nrwahl2-crm_time
Open

Low: libcrmcommon: Ignore empty time spec#4075
nrwahl2 wants to merge 2 commits intoClusterLabs:mainfrom
nrwahl2:nrwahl2-crm_time

Conversation

@nrwahl2
Copy link
Copy Markdown
Contributor

@nrwahl2 nrwahl2 commented Mar 28, 2026

OSS Fuzz found an overflow in crm_time_subtract(), when crm_time_parse_period() was called with the argument "P2752S-596524H-22Y/T". The "T" after the slash was treated as a time spec. However, with nothing after the "T", this is malformed per the ISO 8601 specification.

Pacemaker's time parsing code set the number of seconds to INT_MIN at some point and then tried to negate that value. The fuzzer detected this as potential underflow.

We can avoid this by rejecting a time spec in parse_hms() if we cannot parse at least one field from it using sscanf(). The rc == 0 test was failing because sscanf() returns EOF (a negative integer) when given the empty string after the "T" character. So, we simply check whether rc is less than 1.

Fixes https://issues.oss-fuzz.com/u/1/issues/473156224

Signed-off-by: Reid Wahl nrwahl@protonmail.com

nrwahl2 added 2 commits March 27, 2026 22:08
There is only one call site, and it NULL-checks the argument before the
call.

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
OSS Fuzz found an overflow in crm_time_subtract(), when
crm_time_parse_period() was called with the argument
"P2752S-596524H-22Y/T". The "T" after the slash was treated as a time
spec. However, with nothing after the "T", this is malformed per the ISO
8601 specification.

Pacemaker's time parsing code set the number of seconds to INT_MIN at
some point and then tried to negate that value. The fuzzer detected this
as potential underflow.

We can avoid this by rejecting a time spec in parse_hms() if we cannot
parse at least one field from it using sscanf(). The "rc == 0" test was
failing because sscanf() returns EOF (a negative integer) when given the
empty string after the "T" character. So, we simply check whether rc is
less than 1.

Fixes https://issues.oss-fuzz.com/u/1/issues/473156224

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
@nrwahl2 nrwahl2 requested a review from clumens March 28, 2026 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant