1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 03:30:27 +02:00

web: Gracefully handle premature EOF when reading chunk header.

* module/web/http.scm (read-chunk-header): Return 0 when 'read-line'
  returns EOF.
This commit is contained in:
Ludovic Courtès 2015-09-26 11:04:23 +02:00
parent 4fd7ad6f85
commit 53b8d5f335
2 changed files with 26 additions and 9 deletions

View file

@ -414,6 +414,16 @@
(utf8->string (get-bytevector-n port 6))
(reverse requests)))))
(pass-if-equal "EOF instead of chunk header"
"Only chunk."
;; Omit the second chunk header, leading to a premature EOF. This
;; used to cause 'read-chunk-header' to throw to wrong-type-arg.
;; See the backtrace at
;; <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=19976#5>.
(let* ((str "B\r\nOnly chunk.")
(port (make-chunked-input-port (open-input-string str))))
(get-string-all port)))
(pass-if-equal
(call-with-output-string
(lambda (out-raw)