Skip to content

fix: allow files at exact fileSize limit - #1407

Merged
UlisesGascon merged 2 commits into
expressjs:mainfrom
raashish1601:fix/file-size-boundary
Aug 25, 2026
Merged

UlisesGascon merged 2 commits into
expressjs:mainfrom
raashish1601:fix/file-size-boundary

Conversation

@raashish1601

Copy link
Copy Markdown
Contributor

What changed

  • Increase configured ileSize limit passed to Busboy by 1 byte only when limits.fileSize is explicitly set.
  • This avoids treating an upload exactly equal to limits.fileSize as over-size while preserving the current error for larger uploads.
  • Add regression test for exact-boundary acceptance in est/error-handling.js.

Fixes #1348 (off-by-one file size limit behavior).

@MohammedAlkindi

Copy link
Copy Markdown
Contributor

Confirmed independently, including the case your test doesn't cover.

On current main a 1500-byte file against fileSize: 1500 is rejected, so the bug is real. With this merged into main (the branch is 9 behind, merges clean) 1500 is accepted and 1501 still fails LIMIT_FILE_SIZE, so the boundary moves by exactly one and no further. That over-by-one case is the one worth pinning, since +1 could plausibly have shifted the error instead of removing it.

fileSize: 0 accepts an empty file and rejects one byte, Infinity passes through the isFinite guard untouched, and files: 1 still raises LIMIT_FILE_COUNT.

Suite went 79 to 80 passing; the single failure is a pre-existing Windows path assertion that fails on main too.

@UlisesGascon UlisesGascon self-assigned this Aug 25, 2026
@UlisesGascon
UlisesGascon merged commit 816beea into expressjs:main Aug 25, 2026
28 of 40 checks passed
@UlisesGascon UlisesGascon mentioned this pull request Aug 25, 2026
YasharF added a commit to sahat/hackathon-starter that referenced this pull request Aug 28, 2026
config/morgan.js: colors moved out of the token and into the format string, where morgan doesn't touch them

Dependency Release Notes:

Multer v2.3.0
- Fix [CVE-2026-77078](https://www.cve.org/CVERecord?id=CVE-2026-77078) ([GHSA-wc9g-mqfw-jrwm](GHSA-wc9g-mqfw-jrwm))
- Fix [CVE-2026-77037](https://www.cve.org/CVERecord?id=CVE-2026-77037) ([GHSA-qfvm-cv95-jqjf](GHSA-qfvm-cv95-jqjf))
- Fix [CVE-2026-77063](https://www.cve.org/CVERecord?id=CVE-2026-77063) ([GHSA-qvfw-j98x-7q72](GHSA-qvfw-j98x-7q72))
- Fix [CVE-2026-82333](https://www.cve.org/CVERecord?id=CVE-2026-82333) ([GHSA-535w-7cp7-47q4](GHSA-535w-7cp7-47q4))
- Add `MulterError` codes `INVALID_FIELD_NAME` and `STREAM_DESTROYED`
- Add opt-in `limits.fieldArrayIndexLimit` to bound numeric array indexes in field names ([#1438](expressjs/multer#1438))
- Accept files whose size is exactly `limits.fileSize` ([#1407](expressjs/multer#1407))
- Preserve the caller's async context (`AsyncLocalStorage`) when calling `next()` ([#1124](expressjs/multer#1124))
- Decode WHATWG-escaped characters (`%0A`, `%0D`, `%22`) in `file.originalname` ([#1421](expressjs/multer#1421))
- Do not crash when `fileFilter` invokes its callback more than once ([#1427](expressjs/multer#1427))
- Use a fallback message for `MulterError` codes without a mapping ([#1448](expressjs/multer#1448))
- Docs: clarify `preservePath` and `parts`, use `crypto.randomBytes` in the `DiskStorage` example ([#1414](expressjs/multer#1414), [#1430](expressjs/multer#1430), [#1436](expressjs/multer#1436))
- Docs: add Indonesian, Japanese and Tamil translations and refresh all translations from the current README ([#1431](expressjs/multer#1431), [#1354](expressjs/multer#1354), [#1462](expressjs/multer#1462))
- Internal: run the test suite on Windows ([#1334](expressjs/multer#1334))

Morgan 1.12.0
- Security fix for [CVE-2026-15603](https://www.cve.org/CVERecord?id=CVE-2026-15603)([GHSA-jxfw-x594-9x9m](https://github.com/expressjs/morgan/security/advisories/GHSA-jxfw-x594-9x9m))
- Allow format functions to return objects for streams in `objectMode`
- Respect the `NO_COLOR` environment variable in the `dev` format
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.

multer throws "File too large" error if file size of exact "limits.fileSize" bytes provided.

3 participants