element-hq / dendrite

Dendrite is a second-generation Matrix homeserver written in Go!
https://element-hq.github.io/dendrite/
GNU Affero General Public License v3.0
33 stars 5 forks source link

Dendrite responds incorrectly to invalid media #1994

Open matrixbot opened 3 weeks ago

matrixbot commented 3 weeks ago

This issue was originally created by @ShadowJonathan at https://github.com/matrix-org/dendrite/issues/1994.

Background information

Homeserver in question is jp.cube64128.xyz

These same symptoms are present on dendrite.matrix.org

Description

Dendrite returns a confusing error message to non-existent media;

{"errcode":"M_NOT_FOUND","error":"Failed to download: fileutils.GetPathFromBase64Hash: Invalid filePath (Base64Hash too short - min 3 characters): \"\""}

this MXC is valid, while this one isn't, replacing the latter with matrix.org or any synapse server returns a proper message of "not found"

matrixbot commented 3 weeks ago

This comment was originally posted by @ShadowJonathan at https://github.com/matrix-org/dendrite/issues/1994#issuecomment-908255352.

I'm pretty sure the EOF fallthrough here and the overwriting of err later down there is causing some logic errors; https://github.com/matrix-org/dendrite/blob/802f1c96f804f7a146e4e12e25b20c980a6af870/mediaapi/fileutils/fileutils.go#L133