diff options
author | Mark H Weaver <mhw@netris.org> | 2014-01-21 03:57:04 -0500 |
---|---|---|
committer | Mark H Weaver <mhw@netris.org> | 2014-01-21 03:57:04 -0500 |
commit | ba578eb04460833c5acb1d8f4c08d2facde15e80 (patch) | |
tree | 9fcecf28c314eb14b35efb2c3c18e47bc0dea859 /libguile/r6rs-ports.c | |
parent | a9eca8f5d1bb2a3aabb80b59c54fc355a00a0382 (diff) | |
parent | 611563fb05c18ca52f780746e9963ca9735e9bac (diff) |
Merge branch 'stable-2.0'
Conflicts:
libguile/read.c
test-suite/tests/web-response.test
Diffstat (limited to 'libguile/r6rs-ports.c')
-rw-r--r-- | libguile/r6rs-ports.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/libguile/r6rs-ports.c b/libguile/r6rs-ports.c index fc676895d..a8fc3f187 100644 --- a/libguile/r6rs-ports.c +++ b/libguile/r6rs-ports.c @@ -334,9 +334,11 @@ cbip_fill_input (SCM port) if (c_port->read_pos >= c_port->read_end) { /* Invoke the user's `read!' procedure. */ - unsigned c_octets; + size_t c_octets, c_requested; SCM bv, read_proc, octets; + c_requested = c_port->read_buf_size; + /* Use the bytevector associated with PORT as the buffer passed to the `read!' procedure, thereby avoiding additional allocations. */ bv = SCM_CBIP_BYTEVECTOR (port); @@ -350,8 +352,10 @@ cbip_fill_input (SCM port) == SCM_BYTEVECTOR_LENGTH (bv)); octets = scm_call_3 (read_proc, bv, SCM_INUM0, - SCM_I_MAKINUM (CBIP_BUFFER_SIZE)); - c_octets = scm_to_uint (octets); + scm_from_size_t (c_requested)); + c_octets = scm_to_size_t (octets); + if (SCM_UNLIKELY (c_octets > c_requested)) + scm_out_of_range (FUNC_NAME, octets); c_port->read_pos = (unsigned char *) SCM_BYTEVECTOR_CONTENTS (bv); c_port->read_end = (unsigned char *) c_port->read_pos + c_octets; |