Skip to content

Drop newline in tube.recvline by default#2588

Open
peace-maker wants to merge 7 commits intoGallopsled:devfrom
peace-maker:recvline_drop_newline
Open

Drop newline in tube.recvline by default#2588
peace-maker wants to merge 7 commits intoGallopsled:devfrom
peace-maker:recvline_drop_newline

Conversation

@peace-maker
Copy link
Member

@peace-maker peace-maker commented Jun 19, 2025

This is a breaking change!

Change the default value of the drop parameter to True to avoid the common recvline().strip() dance and be in line with other readline implementations:

Implementations stripping the final newline character when reading a line:

Python's IOBase.readline always includes the trailing newline, except for when there is none on the last line of a file.

My claim is that exploits usually don't care about the trailing newline requiring users to strip it before parsing the line for e.g. address leaks. All other tube.recvline* functions like recvlines or recvline_contains already have drop=True as the default and strip the newline character(s), so this increases the API's consistency.

This will break old exploits that expect the newline in some comparision, but the benefit for newer exploit not having to keep stripping seems to outweight this drawback.

if io.recvline() == b'expected\n': # expected value includes the \n and would break
  ...

line = io.recvline()
return line[:-1] # skip last character

Please leave a comment if there are concerns!

Change the default value of the `drop` parameter to `True` to avoid the common `recvline().strip()` dance and be in line with other readline implementations.
@peace-maker peace-maker force-pushed the recvline_drop_newline branch from 6477a1f to fa6397c Compare June 19, 2025 16:27
@k4lizen
Copy link
Contributor

k4lizen commented Jan 20, 2026

this change makes a lot of sense but the fact that it is breaking really really sucks because exploit.py's are shared through copy-paste rather than a version-locked git repo, so it's impossible to know for which pwntools version a given exploit is intended / will actually work. probably most users aren't going to be aware of this gotcha either :S

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants