Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

max_file_size_bytes = 0 counts as limited file size #2408

Closed
nakoo opened this issue Apr 30, 2022 · 2 comments · Fixed by #2409
Closed

max_file_size_bytes = 0 counts as limited file size #2408

nakoo opened this issue Apr 30, 2022 · 2 comments · Fixed by #2409

Comments

@nakoo
Copy link

nakoo commented Apr 30, 2022

Background information

  • Dendrite version or git SHA: 0.8.2
  • Monolith or Polylith?: Monolith
  • SQLite3 or Postgres?: Postgres
  • Running in Docker?: Yes
  • go version: -
  • Client used (if applicable): Element Web

Description

  • What is the problem:
    When max_file_size_bytes to 0, uploading file doesn't count as unlimited as intended. Fetching file from other servers counts as unlimited.

  • Who is affected: -

  • How is this bug manifesting:

2022-04-30_12-33

  • When did this first appear:
    Set max_file_size_bytes to 0 in dendrite.yaml config file

Steps to reproduce

  • Set max_file_size_bytes to 0 in dendrite.yaml config file
  • Restart the server
  • Try to upload the file
@spaetz
Copy link
Contributor

spaetz commented Apr 30, 2022

Is that not rather a client issue? The spec says:

m.upload.size integer The maximum size an upload can be in bytes. Clients SHOULD use this as a guide when uploading content. If not listed or null, the size limit should be treated as unknown.

Or does 'null' not include zero in this case?

@nakoo
Copy link
Author

nakoo commented Apr 30, 2022

Is that not rather a client issue? The spec says:

m.upload.size integer The maximum size an upload can be in bytes. Clients SHOULD use this as a guide when uploading content. If not listed or null, the size limit should be treated as unknown.

Or does 'null' not include zero in this case?

It seems checkPositive function checks 0.

checkPositive(configErrs, "media_api.max_file_size_bytes", int64(*c.MaxFileSizeBytes))

func checkPositive(configErrs *ConfigErrors, key string, value int64) {
if value < 0 {
configErrs.Add(fmt.Sprintf("invalid value for config key %q: %d", key, value))
}
}

We need to document this part correctly as I mentioned if using 0 is not intended.
(same with build/docker/config/dendrite.yaml)

# The maximum allowed file size (in bytes) for media uploads to this homeserver
# (0 = unlimited). If using a reverse proxy, ensure it allows requests at
# least this large (e.g. client_max_body_size in nginx.)
max_file_size_bytes: 10485760

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants