Skip to content

fuse: safeIntToUint32 does not compile on 32-bit — the overflow guard overflows #198

Closed

Description

@scttfrdmn

internal/fuse/filesystem.go:37 guards an int→uint32 conversion by comparing against a constant that cannot fit a 32-bit int:

func safeIntToUint32(i int) uint32 {
	if i < 0 {
		return 0
	}
	if i > 0xFFFFFFFF {   // <-- on 32-bit platforms this constant overflows int
		return 0xFFFFFFFF
	}
	return uint32(i)
}
$ CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build ./internal/fuse/
internal/fuse/filesystem.go:37:9: 0xFFFFFFFF (untyped int constant 4294967295) overflows int

A compile error, not a runtime bug — internal/fuse cannot be built for any 32-bit target. This is why linux/armv7 was removed from the release matrix in v0.10.1 rather than fixed; the matrix comment records it (.github/workflows/release.yml:56-58).

The fix is to compare in a width that holds the value — if uint64(i) > math.MaxUint32 after the negative check, or math.MaxUint32 typed appropriately — and the same audit applies to safeIntToUint64 directly above it.

Worth doing because 32-bit ARM is real for this project's users (Raspberry Pi collectors, edge instruments writing to S3), and because a guard function that does not compile on the platform whose overflow it guards against is the wrong shape.

Verification: GOARCH=arm GOARM=7 go build ./... succeeds; a table test covering math.MaxUint32, math.MaxUint32+1 (skipped on 32-bit), -1, and 0; then add linux/armv7 back to the release matrix, since a platform that builds but is not shipped is not tested either.

Activity

  1. added
    type: bug
    priority: medium
    area: fuse
    area: build
    effort: xs
    on Aug 2, 2026
  2. scttfrdmn commented on Aug 3, 2026

    @scttfrdmn
    OwnerAuthor

    Reproduced on current main:

    $ GOARCH=386 GOOS=linux go build ./internal/fuse/
    internal/fuse/filesystem.go:37:9: 0xFFFFFFFF (untyped int constant 4294967295) overflows int
    

    The overflow guard overflows at compile time on the architecture it exists to guard. Labelled effort: xs — the fix is the constant's type — but it means internal/fuse has never built for a 32-bit target, so nothing verifies the guard's logic either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: buildarea: fuseeffort: xspriority: mediumtype: bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions