Skip to content

Conversation

@nrwahl2
Copy link
Contributor

@nrwahl2 nrwahl2 commented Nov 18, 2025

Trying to make the function names follow convention a little bit better and deprecate the things that we probably won't need to keep any analog of in the public API.

This is just so that we can guarantee that the argument to
crm_get_utc_time() is non-NULL. All other callers already ensure this.

Signed-off-by: Reid Wahl <[email protected]>
And rename to utc_from_crm_time(), to avoid using a public API prefix.

Signed-off-by: Reid Wahl <[email protected]>
To restore ability to compile with C++ on supported platforms.

This is a repeat of 426eef2. We've been making the same mistake again.

Signed-off-by: Reid Wahl <[email protected]>
@nrwahl2 nrwahl2 requested a review from clumens November 18, 2025 07:31
@nrwahl2 nrwahl2 force-pushed the nrwahl2-time branch 2 times, most recently from 367aa8c to b070ce3 Compare November 18, 2025 09:06
For clarity of purpose and to avoid using public API prefix.

Signed-off-by: Reid Wahl <[email protected]>
It doesn't get the time zone. It converts the seconds member of the time
object to hours and minutes, ignoring any remaining seconds.

Signed-off-by: Reid Wahl <[email protected]>
To avoid using a public API prefix. Also set errno in the callers
instead. It's silly to set it at all, but some public API function
probably calls these, so keep the side effect for backward
compatibility.

Signed-off-by: Reid Wahl <[email protected]>
To avoid using a public API prefix. Also set errno in the caller
instead. It's silly to set it at all, but some public API function
probably calls this, so keep the side effect for backward compatibility.

Signed-off-by: Reid Wahl <[email protected]>
To avoid using a public API prefix. Also stop setting errno. The caller
already sets it if this function returns false.

Rename a goto label to avoid a name conflict. Ideally this label will go
away someday, but we might start using a third-party time library before
that happens.

Signed-off-by: Reid Wahl <[email protected]>
Both crm_time_parse_duration() and parse_date() set errno to EINVAL if
they return NULL. So there's no harm in jumping to the invalid label and
doing it again.

Signed-off-by: Reid Wahl <[email protected]>
So that we can get rid of the forward declaration

Signed-off-by: Reid Wahl <[email protected]>
Move the logic to pcmk__copy_timet(). This means some more allocations
on the heap, but that seems like a worthy tradeoff for simplifying the
interface.

Have crm_time_set_timet() allocate a temporary object using
pcmk__copy_timet() and copy the value to the target.

Signed-off-by: Reid Wahl <[email protected]>
To replace crm_time_get_isoweek(), which doesn't seem as if it needs to
be part of public API.

We could make a case for keeping this public because we allow the use of
ISO week dates in date specifications within rules. Some hypothetical
user might want to get the ISO week date from a crm_time_t and use it to
create a rule. However, that feels a bit contrived, and I think I would
be in favor of deprecating ISO week dates from rules... it's not a ton
of trouble to keep, but it's hard to imagine anyone using it.

Signed-off-by: Reid Wahl <[email protected]>
To replace crm_time_log() and crm_time_log_alias().

Signed-off-by: Reid Wahl <[email protected]>
A lot of functions move around, but no code changes otherwise.

Signed-off-by: Reid Wahl <[email protected]>
@nrwahl2
Copy link
Contributor Author

nrwahl2 commented Nov 18, 2025

retest this please

@nrwahl2
Copy link
Contributor Author

nrwahl2 commented Nov 18, 2025

Remaining CI errors are for repo failures on two PowerPC machines:

[2025-11-18T12:56:36.432Z]   - Curl error (28): Timeout was reached for https://public.dhe.ibm.com/software/server/POWER/Linux/yum/OSS/RHEL/10/ppc64le/repodata/repomd.xml [Failed to connect to public.dhe.ibm.com port 443 after 30001 ms: Timeout was reached]

@nrwahl2
Copy link
Contributor Author

nrwahl2 commented Nov 18, 2025

Dropped the commit that I had just added for "Assert non-NULL in parse_date()", as it was incorrect

More similar to libqb's names.

Signed-off-by: Reid Wahl <[email protected]>
More similar to libqb's names.

Signed-off-by: Reid Wahl <[email protected]>
For clarity and to avoid typos.

Signed-off-by: Reid Wahl <[email protected]>
For clarity and to avoid typos.

Signed-off-by: Reid Wahl <[email protected]>
For clarity and to avoid typos.

Signed-off-by: Reid Wahl <[email protected]>
The fuzzer found an overflow issue. If the sec argument was set to
INT_MIN, then QB_ABS(INT_MIN) would expand to -INT_MIN. Avoid this by
taking the absolute values at the end of the function, after division
and subtraction have ensured that nothing is INT_MIN anymore.

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

Note that the oss-fuzz issue report above is inaccessible at time of
writing, unless you have specifically been granted access.

Signed-off-by: Reid Wahl <[email protected]>
The fuzzer found an underflow here. Somehow crm_time_parse_period() ->
crm_time_subtract() was able to pass INT_MIN as the a_time argument. The
expression ((a_time->years - 1) < 1) underflows if a_time is INT_MIN.

We could avoid this by subtracting 1LL (assuming int is not the same
width as long long), but it seems simpler to use (a_time->years <= 1).

Also update the analogous expression in the (extra > 0) block.

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

Signed-off-by: Reid Wahl <[email protected]>
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