locka99 / opcua

A client and server implementation of the OPC UA specification written in Rust
Mozilla Public License 2.0
475 stars 128 forks source link

subscriptions.rs: Negative `publish_request_timeout` value causes `expire_stale_publish_requests` function to panic #315

Open evanjs opened 3 months ago

evanjs commented 3 months ago

After the time crate removal in #260, if pulish_request_timeout is negative, then subscriptions#expire_stale_publish_requests will panic This is because to_std outputs a Duration, which can only be unsigned (positive).

Since the input value is negative, this will fail immediately.

Here is a playground example of a request timestamp and "now" timestamp that will fail


While this issue was fairly easy to work around, I have no idea if there are any potential implications from this approach. Nor do I know why I might have been seeing negative durations in the first place, beyond non-absolute date synchronization between server/client

Anyway, as seen here