Bug in WireGuard Keepalive Interval validation (66-99 returns invalid)

Hi everyone,

In the version IPFire 2.29 (x86_64) - Core-Update 203, I found a bug in the WireGuard Keepalive Interval field. If you enter a value between 66 to 99, it throws this error:

Oops, something went wrong…
Invalid Keepalive Interval (Must be between 0 and 65535)

I dig into /var/ipfire/wireguard-functions.pl and found the issue. It’s currently using Perl’s string comparison operators:

# Must be between 0 and 65535 (inclusive)
return 0 if ($keepalive lt 0);
return 0 if ($keepalive gt 65535);

Below is the analysis by Deepseek:

Since lt and gt compare strings character by character, “66” is considered greater than “65535” (because the second character ‘6’ > ‘5’). This means any value from 66-99 gets falsely flagged as invalid. (Fun fact: single digits like 7, 8, 9 would probably fail for the same reason!)

The fix is simple, just switch to use numeric comparison:

# Must be between 0 and 65535 (inclusive)
return 0 if ($keepalive < 0);
return 0 if ($keepalive > 65535);

I’ve tested the fix, and it works perfectly now.

You could report it in Bugzilla.

Submitted, thanks for the remind..

Ref: 14039 – Bug in WireGuard Keepalive Interval validation (66-99 returns invalid)