[PR #72] fix: reject out-of-range u16 values #73

Open
opened 2026-10-13 21:03:00 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/amnezia-vpn/amneziawg-tools/pull/72
Author: @HeisLuka
Created: 9/14/2026
Status: 🔄 Open

Base: master ← Head: fix/u16-range-overflow


📝 Commits (1)

  • f742b8f fix: reject out-of-range u16 values

📊 Changes

1 file changed (+4 additions, -2 deletions)

View changed files

📝 src/type.c (+4 -2)

📄 Description

Summary

  • validate u16_range_from_string() inputs against UINT16_MAX instead of UINT32_MAX
  • reset and check errno around both strtoul() calls so overflow is rejected explicitly
  • preserve the existing ascending-range validation

This prevents values above 65535 from being silently truncated when packed into u16_range_t.

Fixes #71

Validation

Compiled the parser with -std=gnu99 -Wall -Wextra -Werror and exercised the boundary cases from #71, including:

  • valid: 0, 1, 65535, 0-65535, 10-20
  • rejected: 65536, 70000, 20-10, 65535-65536, 70000-70010, 4294967295, and an overflowing decimal value

All cases passed.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/amnezia-vpn/amneziawg-tools/pull/72 **Author:** [@HeisLuka](https://github.com/HeisLuka) **Created:** 9/14/2026 **Status:** 🔄 Open **Base:** `master` ← **Head:** `fix/u16-range-overflow` --- ### 📝 Commits (1) - [`f742b8f`](https://github.com/amnezia-vpn/amneziawg-tools/commit/f742b8f5780e6609fcfe429d3b05e83b0e43dd53) fix: reject out-of-range u16 values ### 📊 Changes **1 file changed** (+4 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/type.c` (+4 -2) </details> ### 📄 Description ## Summary - validate `u16_range_from_string()` inputs against `UINT16_MAX` instead of `UINT32_MAX` - reset and check `errno` around both `strtoul()` calls so overflow is rejected explicitly - preserve the existing ascending-range validation This prevents values above `65535` from being silently truncated when packed into `u16_range_t`. Fixes #71 ## Validation Compiled the parser with `-std=gnu99 -Wall -Wextra -Werror` and exercised the boundary cases from #71, including: - valid: `0`, `1`, `65535`, `0-65535`, `10-20` - rejected: `65536`, `70000`, `20-10`, `65535-65536`, `70000-70010`, `4294967295`, and an overflowing decimal value All cases passed. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
amnezia-vpn/amneziawg-tools#73
No description provided.