Page MenuHomePhabricator

Fix an issue with removing bytes in PhutilRope
ClosedPublic

Authored by epriestley on Dec 16 2015, 8:30 PM.
Tags
None
Referenced Files
F11149930: D14801.id35788.diff
Sun, Sep 25, 12:39 AM
Unknown Object (File)
Mon, Sep 12, 5:56 PM
Unknown Object (File)
Aug 9 2022, 11:10 PM
Unknown Object (File)
Aug 5 2022, 10:06 PM
Unknown Object (File)
Jul 5 2022, 5:30 AM
Unknown Object (File)
Jun 27 2022, 7:29 PM
Unknown Object (File)
Jun 11 2022, 12:07 PM
Unknown Object (File)
Jun 9 2022, 2:34 PM
Subscribers
None

Details

Summary

Via HackerOne, although this is not a security issue. PhutilRope does have a bug with byte handling, though.

Test Plan

Added a failing test and made it pass.

Diff Detail

Repository
rPHU libphutil
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

epriestley retitled this revision from to Fix an issue with removing bytes in PhutilRope.
epriestley updated this object.
epriestley edited the test plan for this revision. (Show Details)
epriestley added a reviewer: chad.
chad edited edge metadata.
This revision is now accepted and ready to land.Dec 16 2015, 8:30 PM
src/utils/PhutilRope.php
102

The bug was here: we incorrectly used $length instead of $remaining_length, so we could strip too many bytes off the buffer. I've tried to rename variables to make the method more clear, since $len, $length and $remaining_length were fairly confusing.

src/utils/__tests__/PhutilRopeTestCase.php
33

Prior to this fix, this incorrectly output "ddddddddd".

This revision was automatically updated to reflect the committed changes.