Bug 14039

Summary: Bug in WireGuard Keepalive Interval validation (66-99 returns invalid)
Product: IPFire Reporter: apr3020 ipf <saberry233>
Component: ---Assignee: Assigned to nobody - feel free to grab it and work on it <nobody>
Status: NEW --- QA Contact:
Severity: - Unknown -    
Priority: - Unknown -    
Version: 2   
Hardware: all   
OS: All   

Description apr3020 ipf 2026-08-14 10:06:42 UTC
[Original post](https://community.ipfire.org/t/bug-in-wireguard-keepalive-interval-validation-66-99-returns-invalid/16079)

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.