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

Get rid of more int casts in file size manipulations #38196

Merged
merged 2 commits into from May 15, 2023

Conversation

come-nc
Copy link
Contributor

@come-nc come-nc commented May 11, 2023

Summary

On 32bits sizes may be floats. There were a few places where this was still not taken into account.

I did not fix the following:

lib/private/Files/ObjectStore/S3.php:           return (int)$stat->get('ContentLength');
lib/private/Files/ObjectStore/ObjectStoreStorage.php:           $stat['size'] = (int)$size;

Because it would bubble up to the interface IObjectStoreMultiPartUpload in OCP, and I’m not sure if it is possible/easy to support floats there.

Also did not fix:

lib/private/Files/Stream/Encryption.php:                        $positionInFile = (int)floor($this->position / $this->unencryptedBlockSize) *
lib/private/Files/Stream/Encryption.php:                $newFilePosition = (int)floor($newPosition / $this->unencryptedBlockSize)
lib/private/Files/Stream/Encryption.php:                $position = (int)floor($this->position / $this->unencryptedBlockSize);
lib/private/Files/Stream/Encryption.php:                        $position = (int)floor($this->position / $this->unencryptedBlockSize);
lib/private/Files/Stream/Encryption.php:                        $completeBlocksInFile = (int)floor($this->unencryptedSize / $this->unencryptedBlockSize);
lib/private/Files/Stream/Encryption.php:                        if ($completeBlocksInFile === (int)floor($this->position / $this->unencryptedBlockSize)) {
lib/private/Files/Stream/Encryption.php:                        $position = (int)floor($this->position / $this->unencryptedBlockSize);
lib/private/Files/Stream/Encryption.php:                        $numberOfChunks = (int)($this->unencryptedSize / $this->unencryptedBlockSize);

It’s not clear if those can overflow or not.

Checklist

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
@come-nc come-nc added bug 2. developing Work in progress labels May 11, 2023
@come-nc come-nc self-assigned this May 11, 2023
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
@come-nc come-nc added 3. to review Waiting for reviews and removed 2. developing Work in progress labels May 15, 2023
@come-nc come-nc added this to the Nextcloud 27 milestone May 15, 2023
@come-nc come-nc requested review from a team, ArtificialOwl, icewind1991, Fenn-CS, artonge and szaimen and removed request for a team May 15, 2023 12:40
@szaimen szaimen removed their request for review May 15, 2023 12:42
@come-nc
Copy link
Contributor Author

come-nc commented May 15, 2023

/backport to stable26

@come-nc
Copy link
Contributor Author

come-nc commented May 15, 2023

/backport to stable25

@come-nc come-nc merged commit 8362eea into master May 15, 2023
36 of 37 checks passed
@come-nc come-nc deleted the fix/fix-32bits-freespace-and-sizes branch May 15, 2023 15:05
@blizzz blizzz mentioned this pull request May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Error “Your storage is full, files can not be updated or synced anymore!"
3 participants