Skip to content

serve dlna: fix crash on Browse with a negative StartingIndex or RequestedCount - #10221

Merged
ncw merged 1 commit into
rclone:masterfrom
hsdfat:serve-dlna-browse-negative-index
Nov 5, 2026
Merged

ncw merged 1 commit into
rclone:masterfrom
hsdfat:serve-dlna-browse-negative-index

Conversation

@hsdfat

@hsdfat hsdfat commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

What does this change do?

ContentDirectory#Browse sliced the child list with StartingIndex and RequestedCount straight from the SOAP body. A negative value (both are ui4 in the SCPD, but nothing enforced that) panicked with slice bounds out of range. The logging middleware recovered it, so the client got a plain-text 500 with the Go runtime error instead of a UPnP fault.

Browse now rejects negative values with UPnP error 600 (Argument Value Invalid), the code already used for an unknown BrowseFlag. RequestedCount == 0 still means "all".

TestContentDirectoryBrowseNegativeIndex covers (-1, 0) and (0, -1); both panic on master.

Linked issue

None. Small bug fix found while reading the handler.

Checklist

  • This change is trivial OR it has been discussed and agreed in the linked issue.
  • I have read the contribution guidelines.
  • (If I used AI tools to help write this code) I have read and understood the AI-assisted contributions guidance, and I have tested and take ownership of this change myself.
  • I have added tests for all changes in this PR if appropriate.
  • I have added documentation for the changes if appropriate.
  • All commit messages are in house style.
  • (Backend changes only) test_all passes for this backend and if submitting a new backend can provide a test account for the integration tester - see CONTRIBUTING.md.
  • This Pull Request is ready for review.

…estedCount

A Browse request with a negative StartingIndex or RequestedCount made
the handler panic slicing the directory listing, so the client got a
plain text 500 with the Go runtime error instead of a SOAP fault.

These arguments are ui4 in the ContentDirectory SCPD, so reject
negative values with the UPnP "Argument Value Invalid" (600) error.
@hsdfat
hsdfat requested review from albertony and ncw as code owners October 30, 2026 23:10

@agammann agammann left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The guard rejects negative Browse arguments before either value reaches the child-list slicing code. Both negative cases now produce the existing UPnP argument-value error, and the full DLNA package test suite passed on head ab55d06 with go test -count=1 ./cmd/serve/dlna.

@ncw ncw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you - very nice fix :-)

@ncw
ncw merged commit 5795966 into rclone:master Nov 5, 2026
9 checks passed
@hsdfat
hsdfat deleted the serve-dlna-browse-negative-index branch November 6, 2026 11:28
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