fix: use a larger maxChunk size when using 64-bit platforms #126

Merged
nemith merged 1 commit from brb/push-prkxnwkmomtv into main 2026-01-07 18:26:47 +00:00
nemith commented 2026-01-07 18:16:50 +00:00 (Migrated from github.com)

Minor fix. the size returned from an io.Writer is an signed int which limits how much we can write on 32-bit platforms (2GB) so limit it using Math.MaxInt

In practice no client is sending 2+GB over NETCONF...hopefully.

Minor fix. the size returned from an `io.Writer` is an signed `int` which limits how much we can write on 32-bit platforms (2GB) so limit it using `Math.MaxInt` In practice no client is sending 2+GB over NETCONF...hopefully.
copilot-pull-request-reviewer[bot] (Migrated from github.com) reviewed 2026-01-07 18:18:58 +00:00
copilot-pull-request-reviewer[bot] (Migrated from github.com) left a comment

Pull request overview

This PR addresses platform-specific limitations in chunked framing by adjusting the maximum chunk size to be architecture-aware. Instead of capping at MaxInt32 (~2GB) on all platforms, the code now uses MaxInt which allows for larger chunks on 64-bit systems while maintaining safety on 32-bit systems.

Key Changes:

  • Replaced fixed MaxInt32 limit with architecture-aware MaxInt constant
  • Refactored chunk size calculation to use the min() function for cleaner code
  • Updated documentation to explain RFC 6242 compliance and cross-architecture compatibility

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

## Pull request overview This PR addresses platform-specific limitations in chunked framing by adjusting the maximum chunk size to be architecture-aware. Instead of capping at MaxInt32 (~2GB) on all platforms, the code now uses MaxInt which allows for larger chunks on 64-bit systems while maintaining safety on 32-bit systems. **Key Changes:** - Replaced fixed MaxInt32 limit with architecture-aware MaxInt constant - Refactored chunk size calculation to use the `min()` function for cleaner code - Updated documentation to explain RFC 6242 compliance and cross-architecture compatibility --- 💡 <a href="/nemith/netconf/new/main/.github/instructions?filename=*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.
@ -336,0 +336,4 @@
// maxChunkSize is the maximum chunk size for RFC 6242 chunked framing.
// RFC 6242 allows up to MaxUint32 (4294967295), but on 32-bit systems
// slice lengths are limited to MaxInt32. We use the minimum of both
// to ensure compatibility across all architectures.
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-01-07 18:18:57 +00:00

The comment states "slice lengths are limited to MaxInt32" but this is only accurate for 32-bit systems. On 64-bit systems, slice lengths can be up to MaxInt (which is MaxInt64 on 64-bit platforms). The comment should clarify that the limit is MaxInt32 on 32-bit systems and MaxInt64 on 64-bit systems, or simply state that slice lengths are limited to MaxInt (which is architecture-dependent).

	// RFC 6242 allows up to MaxUint32 (4294967295), but Go slice lengths are
	// limited by MaxInt (MaxInt32 on 32-bit systems, MaxInt64 on 64-bit systems).
	// We use the minimum of both to ensure compatibility across all architectures.
The comment states "slice lengths are limited to MaxInt32" but this is only accurate for 32-bit systems. On 64-bit systems, slice lengths can be up to MaxInt (which is MaxInt64 on 64-bit platforms). The comment should clarify that the limit is MaxInt32 on 32-bit systems and MaxInt64 on 64-bit systems, or simply state that slice lengths are limited to MaxInt (which is architecture-dependent). ```suggestion // RFC 6242 allows up to MaxUint32 (4294967295), but Go slice lengths are // limited by MaxInt (MaxInt32 on 32-bit systems, MaxInt64 on 64-bit systems). // We use the minimum of both to ensure compatibility across all architectures. ```
Sign in to join this conversation.
No description provided.