Skip to content
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

Fix integer overflow on 32-bit systems when testing free space for wr… #36759

Merged
merged 1 commit into from
Feb 20, 2023

Conversation

sgolovan
Copy link
Contributor

…iting a config file.

Summary

This trivial commit fixes integer overflow on 32-bit systems when trying to write back config.php on upgrade.

The bug is introduced recently, in commit 9b6e5c6

@szaimen
Copy link
Contributor

szaimen commented Feb 17, 2023

cc @come-nc since you have a bit experience with 32-bit: what would be the best approach to fix this? Is checking against float even possible?

@szaimen szaimen added bug 3. to review Waiting for reviews feature: 32bits Bug specific to 32bits architectures labels Feb 17, 2023
@szaimen szaimen requested a review from come-nc February 17, 2023 09:17
@szaimen szaimen added this to the Nextcloud 26 milestone Feb 17, 2023
@szaimen szaimen added the high label Feb 17, 2023
@szaimen szaimen requested review from a team, ArtificialOwl and icewind1991 and removed request for a team February 17, 2023 09:39
@MichaIng
Copy link
Member

Just ran into the same issue on beta 4 upgrade. Removing (int) alone solved it. For comparison it doesn't seem to be required to cast the size of the config file from int to float, and a config file > 2 GiB shouldn't be possible anyway.

@szaimen
Copy link
Contributor

szaimen commented Feb 17, 2023

Just ran into the same issue on beta 4 upgrade. Removing (int) alone solved it. For comparison it doesn't seem to be required to cast the size of the config file from int to float, and a config file > 2 GiB shouldn't be possible anyway.

Psalm complains without...

@MichaIng
Copy link
Member

MichaIng commented Feb 17, 2023

You mean if not both are int or both are float? Then we need to cast both to float before comparing (as on 64-bit free space will usually be int?), doing the same in all other cases where numerical values are compared which can be >2 GiB. How was such done before the temporary decision to drop 32-bit support?

Copy link
Contributor

@come-nc come-nc left a comment

Choose a reason for hiding this comment

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

I’m not even sure why a cast is needed, what does psalm complains about without it?

Copy link
Contributor

@szaimen szaimen left a comment

Choose a reason for hiding this comment

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

fine by me then

@szaimen szaimen added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Feb 20, 2023
@szaimen szaimen merged commit 3204f97 into nextcloud:master Feb 20, 2023
@welcome
Copy link

welcome bot commented Feb 20, 2023

Thanks for your first pull request and welcome to the community! Feel free to keep them coming! If you are looking for issues to tackle then have a look at this selection: https://github.com/nextcloud/server/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22

@MichaIng
Copy link
Member

Still not sure why we cast the config file size to float now?

@skjnldsv skjnldsv mentioned this pull request Feb 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4. to release Ready to be released and/or waiting for tests to finish bug feature: 32bits Bug specific to 32bits architectures high
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants