Skip to content

DatabaseBackend::get is a panic waiting to happen #1066

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jyn514 opened this issue Sep 25, 2020 · 1 comment
Closed

DatabaseBackend::get is a panic waiting to happen #1066

jyn514 opened this issue Sep 25, 2020 · 1 comment
Labels
C-bug Category: This is a bug P-low Low priority issues

Comments

@jyn514
Copy link
Member

jyn514 commented Sep 25, 2020

(CASE WHEN LENGTH(content) <= $2 THEN content ELSE NULL END) AS content,
returns NULL if the file is too big. But blob.content is a Vec, not an Option<Vec>. So
content: row.get("content"),
will panic whenever the content is NULL.

Fortunately, the database backend isn't used in prod, but this is something to be aware of when self-hosting or running tests.

This was caught while working on #874.

@jyn514 jyn514 added C-bug Category: This is a bug P-low Low priority issues labels Sep 25, 2020
@jyn514
Copy link
Member Author

jyn514 commented Sep 25, 2020

Oh hold on, this explicitly checks for the case when it's NULL above:

(LENGTH(content) > $2) AS is_too_big

and
if row.get("is_too_big") {
return Err(std::io::Error::new(

So this can't be hit even in theory.

@jyn514 jyn514 closed this as completed Sep 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug P-low Low priority issues
Projects
None yet
Development

No branches or pull requests

1 participant