Skip to content

Conversation

jiuker
Copy link
Contributor

@jiuker jiuker commented May 27, 2025

fix: empty fileName cause Reader nil for PostPolicyBucketHandler

Community Contribution License

All community contributions in this pull request are licensed to the project maintainers
under the terms of the Apache 2 license.
By creating this pull request I represent that I have the right to license the
contributions to the project maintainers under the Apache 2 license.

Description

We will got a nil Reader if the fileName is empty.

We ignore here:

name := part.FormName()
if name == "" {
continue
}

fix #21319

Motivation and Context

How to test this PR?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Optimization (provides speedup with no functional changes)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • Fixes a regression (If yes, please add commit-id or PR # here)
  • Unit tests added/updated
  • Internal documentation updated
  • Create a documentation update request here

fix: empty fileName cause Reader nil for PostPolicyBucketHandler
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Fix the case where an empty fileName in the form causes reader to remain nil, resulting in a nil-pointer error in PostPolicyBucketHandler.

  • Added a nil check for reader to return a clear malformed-request error
  • Preserved existing error-wrapping style for missing form fields
Comments suppressed due to low confidence (1)

cmd/bucket-handlers.go:1093

  • Add a unit test covering the scenario where the form has no file (i.e. reader == nil) to ensure this error path is exercised.
if reader == nil {

Copy link
Member

@harshavardhana harshavardhana left a comment

Choose a reason for hiding this comment

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

We should add a test for this in mint.

@harshavardhana harshavardhana merged commit 9f24ca5 into minio:master May 27, 2025
21 checks passed
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.

Crash when uploading using Presigned POST URL — panic in etag.Reader.Read
3 participants