File name too long error uploading profile image #146

Open
opened 2021-09-02 13:48:08 +00:00 by jpds · 8 comments
jpds commented 2021-09-02 13:48:08 +00:00 (Migrated from gitlab.com)

Description

I tried to set in Element a profile image with a filename of 147 characters and conduit returned a 500 server error.

System Configuration

Conduit Version: 0.2.0
Database backend (default is sqlite): sqlite

### Description I tried to set in Element a profile image with a filename of 147 characters and conduit returned a 500 server error. ### System Configuration Conduit Version: 0.2.0 Database backend (default is sqlite): sqlite
jfowl commented 2021-09-02 15:58:41 +00:00 (Migrated from gitlab.com)

I'm working on finding out, why this failed.

Log:

WARN conduit::error: 500 Internal Server Error: Could not do this io: File name too long (os error 36)

URL called by element upon trying to set profile picture:

http://localhost:6167/_matrix/media/r0/upload?filename=<long-file-name>
I'm working on finding out, why this failed. Log: ``` WARN conduit::error: 500 Internal Server Error: Could not do this io: File name too long (os error 36) ``` URL called by element upon trying to set profile picture: ``` http://localhost:6167/_matrix/media/r0/upload?filename=<long-file-name> ```
timokoesters commented 2021-09-02 16:05:03 +00:00 (Migrated from gitlab.com)

So conduit saves the media as a file with a filename based on a base64'd version of the uploaded file name, I will look into why exactly we need that.

So conduit saves the media as a file with a filename based on a base64'd version of the uploaded file name, I will look into why exactly we need that.
timokoesters commented 2021-09-02 16:15:12 +00:00 (Migrated from gitlab.com)

Looks like there is no particular reason other than code reuse. We can fix this by giving get_media_file in src/database/media.rs just msc and width, height as parameters and writing a migration in database.rs that renames all existing files with this algorithm: take existing filename, deserialize base64, call rsplitn with 3 and 0xff, taking only the last slice returned from that (index 2) and using that as the new filename.

Looks like there is no particular reason other than code reuse. We can fix this by giving get_media_file in src/database/media.rs just msc and width, height as parameters and writing a migration in database.rs that renames all existing files with this algorithm: take existing filename, deserialize base64, call rsplitn with 3 and 0xff, taking only the last slice returned from that (index 2) and using that as the new filename.
jfowl commented 2022-02-20 09:35:24 +00:00 (Migrated from gitlab.com)

@timokoesters did we not already fix this issue?

@jpds does this issue still exist for you?

@timokoesters did we not already fix this issue? @jpds does this issue still exist for you?
M0dEx commented 2022-04-06 18:44:22 +00:00 (Migrated from gitlab.com)

assigned to @M0dEx

assigned to @M0dEx
Orhideous commented 2022-11-21 21:38:33 +00:00 (Migrated from gitlab.com)

This bug still present.

MatrixError: [500] Could not do this io: File name too long (os error 36) (https://example.com/_matrix/media/r0/upload?filename=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.jpg)
This bug still present. ``` MatrixError: [500] Could not do this io: File name too long (os error 36) (https://example.com/_matrix/media/r0/upload?filename=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.jpg) ```
shekohex commented 2023-04-24 20:08:04 +00:00 (Migrated from gitlab.com)

A possible fix actually could also by passing the result of Database::create_file_metadata to a hashing function, which will output a fixed-length and unique file name(s). A SHA3 or even SHA2 Would be good use case here. I'm working on a possible fix right now for this.

A possible fix actually could also by passing the result of `Database::create_file_metadata` to a hashing function, which will output a fixed-length and unique file name(s). A SHA3 or even SHA2 Would be good use case here. I'm working on a possible fix right now for this.
shekohex commented 2023-04-24 20:56:24 +00:00 (Migrated from gitlab.com)

mentioned in merge request !467

mentioned in merge request !467
Sign in to join this conversation.
No labels
Android
CS::needs customer feedback
CS::needs follow up
CS::needs on prem installation
CS::waiting
Chrome
Design:: Ready
Design:: in progress
Design::UX
E2EE
Edge
Firefox
GDPR
Iteration 13 IM
Linux
MacOS
Need::Discussion
Need::Steps to reproduce
Need::Upstream fix
Needs:: Planning
Needs::Dev-Team
Needs::More information
Needs::Priority
Needs::Product
Needs::Refinement
Needs::Severity
Priority::1-Critical
Priority::2-Max
Priority::3-Impending
Priority::4-High
Priority::5-Medium
Priority::6-Low
Priority::7-None
Progress::Backlog
Progress::Review
Progress::Started
Progress::Testing
Progress::Triage
Progress::Waiting
Reporter::Sentry
Safari
Target::Community
Target::Customer
Target::Internal
Target::PoC
Target::Security
Team:Customer-Success
Team:Design
Team:Infrastructure
Team:Instant-Messaging
Team:Product
Team:Workflows
Type::Bug
Type::Design
Type::Documentation
Type::Feature
Type::Improvement
Type::Support
Type::Tests
Windows
blocked
blocked-by-spec
cla-signed
conduit
contribution::advanced
contribution::easy
contribution::help needed
from::review
iOS
p::ti-tenant
performance
product::triage
proposal
refactor
release-blocker
s: dart_openapi_codegen
s::Famedly-Patient
s::Org-Directory
s::Passport-Generator
s::Requeuest
s:CRM
s:Famedly-App
s:Famedly-Web
s:Fhiroxide
s:Fhiroxide-cli
s:Fhiroxide-client
s:Fhirs
s:Hedwig
s:LISA
s:Matrix-Dart-SDK
s:Role-Manager
s:Synapse
s:User-Directory
s:WFS-Matrix
s:Workflow Engine
s:dtls
s:famedly-error
s:fcm-shared-isolate
s:matrix-api-lite
s:multiple-tab-detector
s:native-imaging
severity::1
severity::2
severity::3
severity::4
technical-debt
voip
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Matthias/conduit#146
No description provided.