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

Add memory limits #8

Open
r13l opened this issue Apr 21, 2021 · 1 comment
Open

Add memory limits #8

r13l opened this issue Apr 21, 2021 · 1 comment

Comments

@r13l
Copy link

r13l commented Apr 21, 2021

READ-LINE* currently has no maximum line length, but will instead continue to read input until memory is exhausted. While this default should probably not be changed (there may very well be someone somewhere who is reading multi-gigabyte lines), it would enhance stability to allow callers of the library to specify a maximum line length:

(let ((chunga:*max-line-length* 8192))
  (chunga:read-line* stream))
@r13l
Copy link
Author

r13l commented Apr 21, 2021

The following program illustrates the problem (using HUNCHENTOOT, which ultimately calls CHUNGA:READ-LINE):

(ql:quickload '("hunchentoot"))
(hunchentoot:start (make-instance 'hunchentoot:easy-acceptor :port 4242))

(let ((sock (make-instance 'sb-bsd-sockets:inet-socket :type :stream :protocol :tcp))
      ss)
  (sb-bsd-sockets:socket-connect sock #(127 0 0 1) 4242)
  (setq ss (sb-bsd-sockets:socket-make-stream sock :output t :input t :buffering :none :element-type 'character :auto-close t))
  (format ss "GET / HTTP/1.0~c~c" #\Return #\Newline)
  (loop (write-char #\a ss)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant