[erlang-patches] Limit maximum line length in interactive shells

Stefan Zegenhagen stefan.zegenhagen@REDACTED
Tue May 7 14:29:44 CEST 2013


Dear all,


one of our testers found out that he could reliably reboot our
erlang-based device by just sending tons of 'A' characters to an
interactive shell.

It appears that the I/O server of the interactive shell (in group.erl)
is always reading a full line before doing any end-of-input processing,
so that by sending bytes without a newline in between, it slowly eats up
all available memory.

The patch attached to this e-mail fixes that by introducing a new
io:setopt() option in group.erl named 'max_length' that is used to check
whether the current line length exceeds this maximum whenever the line
is edited. If an overlong line is detected, max_length bytes are
returned immediately (without the actual stop condition being fulfilled,
though, allowing I/O clients to detect this situation).

max_length is allowed to be an integer() > 0 or 'unlimited'. The default
is 'unlimited' to have the old behaviour by default.



Kind regards,

-- 
Dr. Stefan Zegenhagen

arcutronix GmbH
Garbsener Landstr. 10
30419 Hannover
Germany

Tel:   +49 511 277-2734
Fax:   +49 511 277-2709
Email: stefan.zegenhagen@REDACTED
Web:   www.arcutronix.com

*Synchronize the Ethernet*

General Managers: Dipl. Ing. Juergen Schroeder, Dr. Josef Gfrerer -
Legal Form: GmbH, Registered office: Hannover, HRB 202442, Amtsgericht
Hannover; Ust-Id: DE257551767.

Please consider the environment before printing this message.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: line_length.patch
Type: text/x-patch
Size: 10335 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-patches/attachments/20130507/33577f59/attachment.bin>


More information about the erlang-patches mailing list