Skip to content

Cap the size of an opened .eap-config file - #185

Merged
SanderVeer merged 1 commit into
mainfrom
bugfix/eap-config-oom
Nov 6, 2026
Merged

SanderVeer merged 1 commit into
mainfrom
bugfix/eap-config-oom

Conversation

@SanderVeer

Copy link
Copy Markdown
Collaborator

On Chromebooks, opening an .eap-config file crashed with an OutOfMemoryError in readBytes (Crashlytics f4def939, 278 events in a week, all on 2.3.1(2693)). Every sampled event failed on the same 128 MB allocation, so the stream held more than 64 MB. The chunked reader from the earlier OOM fix buffered the whole stream with no limit, and Route.buildDeepLink only catches Exception, not OutOfMemoryError.

readBytes now throws FileTooLargeException once the stream passes 10 MB, which buildDeepLink already catches. The user sees the "Not a valid .eap-config file" message instead of a crash. Real profiles are well below 1 MB.

This adds the first unit test source set, with the JUnit alias in the version catalog.

On Chromebooks, opening an .eap-config file crashed with an
OutOfMemoryError in readBytes (Crashlytics f4def939, 278 events in a
week, all on 2.3.1(2693)). Every sampled event failed on the same
128 MB allocation, so the stream held more than 64 MB. The chunked
reader from the earlier OOM fix buffered the whole stream with no
limit, and Route.buildDeepLink only catches Exception, not
OutOfMemoryError.

readBytes now throws FileTooLargeException once the stream passes
10 MB, which buildDeepLink already catches. The user sees the "Not a
valid .eap-config file" message instead of a crash. Real profiles are
well below 1 MB.

This adds the first unit test source set, with the JUnit alias in the
version catalog.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the change that caps .eap-config stream reads to prevent unbounded buffering.

No open issues 🎉

What changed in this PR

Caps .eap-config stream reads at 10 MiB to prevent unbounded buffering and let the existing error handler reject oversized files instead of crashing.

Changes:

  • Adds a configurable read limit and FileTooLargeException.
  • Adds unit tests for normal reads, size boundaries, endless streams, and stream closure when the limit is exceeded.
  • Configures JUnit for the Android app’s first unit tests.
File Description
gradle/​libs.versions.toml Adds the JUnit library alias.
android/​app/​src/​test/​java/​app/​eduroam/​geteduroam/​extensions/​InputStreamTest.kt Tests bounded reads and stream cleanup.
android/​app/​src/​main/​java/​app/​eduroam/​geteduroam/​extensions/​InputStream.kt Enforces the read limit before buffering excess data.
android/​app/​build.gradle.kts Adds JUnit as a test dependency.

Review effort: Balanced

@SanderVeer
SanderVeer marked this pull request as ready for review November 6, 2026 14:48
@SanderVeer
SanderVeer requested a review from dzolnai November 6, 2026 14:49
@SanderVeer
SanderVeer merged commit 5d61551 into main Nov 6, 2026
2 checks passed
@SanderVeer
SanderVeer deleted the bugfix/eap-config-oom branch November 6, 2026 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants