guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] GNU Guile branch, master, updated. release_1-9-13-129-ge


From: Andy Wingo
Subject: [Guile-commits] GNU Guile branch, master, updated. release_1-9-13-129-ge8c44a0
Date: Sat, 04 Dec 2010 18:43:10 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=e8c44a044f643671a9e5779048e422d16f67d422

The branch, master has been updated
       via  e8c44a044f643671a9e5779048e422d16f67d422 (commit)
       via  f3d390939b841067917beb821075368a6395dccc (commit)
      from  3ef6650def28f7c29a2cc983086468d3195167d4 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit e8c44a044f643671a9e5779048e422d16f67d422
Author: Andy Wingo <address@hidden>
Date:   Sat Dec 4 19:45:51 2010 +0100

    (web server http) comment
    
    * module/web/server/http.scm: Add comment about charsets.

commit f3d390939b841067917beb821075368a6395dccc
Author: Andy Wingo <address@hidden>
Date:   Sat Dec 4 19:45:09 2010 +0100

    fix error handling in read-{request,response}-body/latin-1
    
    * module/web/request.scm (read-request-body/latin-1):
    * module/web/response.scm (read-response-body/latin-1): Detect short
      reads instead of returning a full buffer with the last bits zeroed
      out. (Before the make-string commit, they contained uninitialized
      memory, which was a fairly serious error.)

-----------------------------------------------------------------------

Summary of changes:
 module/web/request.scm     |    9 ++++++---
 module/web/response.scm    |    9 ++++++---
 module/web/server/http.scm |    8 ++++++++
 3 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/module/web/request.scm b/module/web/request.scm
index 78cf0ee..3451b8a 100644
--- a/module/web/request.scm
+++ b/module/web/request.scm
@@ -195,9 +195,12 @@
 (define (read-request-body/latin-1 r)
   (let ((nbytes (request-content-length r)))
     (and nbytes
-         (let ((buf (make-string nbytes)))
-           (read-delimited! "" buf (request-port r))
-           buf))))
+         (let* ((buf (make-string nbytes))
+                (n (read-delimited! "" buf (request-port r))))
+           (if (= n nbytes)
+               buf
+               (bad-request "EOF while reading request body: ~a bytes of ~a"
+                            n nbytes))))))
 
 ;; Likewise, assumes that body can be written in the latin-1 encoding,
 ;; and that the latin-1 encoding is what is expected by the server.
diff --git a/module/web/response.scm b/module/web/response.scm
index ef222f7..a4b1cb9 100644
--- a/module/web/response.scm
+++ b/module/web/response.scm
@@ -187,9 +187,12 @@
 (define (read-response-body/latin-1 r)
   (let ((nbytes (response-content-length r)))
     (and nbytes
-         (let ((buf (make-string nbytes)))
-           (read-delimited! "" buf (response-port r))
-           buf))))
+         (let* ((buf (make-string nbytes))
+                (n (read-delimited! "" buf (response-port r))))
+           (if (= n nbytes)
+               buf
+               (bad-response "EOF while reading response body: ~a bytes of ~a"
+                             n nbytes))))))
 
 ;; Likewise, assumes that body can be written in the latin-1 encoding,
 ;; and that the latin-1 encoding is what is expected by the server.
diff --git a/module/web/server/http.scm b/module/web/server/http.scm
index 46dcbb2..150b73e 100644
--- a/module/web/server/http.scm
+++ b/module/web/server/http.scm
@@ -17,6 +17,14 @@
 ;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 ;; 02110-1301 USA
 
+;;; Commentary:
+;;;
+;;; This is the HTTP implementation of the (web server) interface.
+;;;
+;;; `read-request' sets the character encoding on the new port to
+;;; latin-1.  See the note in request.scm regarding character sets,
+;;; strings, and bytevectors for more information.
+;;;
 ;;; Code:
 
 (define-module (web server http)


hooks/post-receive
-- 
GNU Guile



reply via email to

[Prev in Thread] Current Thread [Next in Thread]