mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-30 06:50:31 +02:00
Fix range checking in new Scheme-to-C port code
* libguile/ports.c (trampoline_to_c_read, trampoline_to_c_write): Fix bugs checking ranges of start and count parameters.
This commit is contained in:
parent
2c95a21027
commit
4e288ec2ff
1 changed files with 6 additions and 4 deletions
|
@ -172,10 +172,11 @@ trampoline_to_c_read (SCM port, SCM dst, SCM start, SCM count)
|
|||
size_t c_start, c_count, ret;
|
||||
|
||||
SCM_VALIDATE_OPPORT (1, port);
|
||||
SCM_VALIDATE_BYTEVECTOR (2, dst);
|
||||
c_start = scm_to_size_t (start);
|
||||
c_count = scm_to_size_t (count);
|
||||
SCM_ASSERT_RANGE (2, start, c_start <= c_count);
|
||||
SCM_ASSERT_RANGE (3, count, c_start+c_count <= scm_c_bytevector_length (dst));
|
||||
SCM_ASSERT_RANGE (3, start, c_start <= SCM_BYTEVECTOR_LENGTH (dst));
|
||||
SCM_ASSERT_RANGE (4, count, c_count <= SCM_BYTEVECTOR_LENGTH (dst) - c_start);
|
||||
|
||||
ret = SCM_PORT_TYPE (port)->c_read (port, dst, c_start, c_count);
|
||||
|
||||
|
@ -198,10 +199,11 @@ trampoline_to_c_write (SCM port, SCM src, SCM start, SCM count)
|
|||
size_t c_start, c_count, ret;
|
||||
|
||||
SCM_VALIDATE_OPPORT (1, port);
|
||||
SCM_VALIDATE_BYTEVECTOR (2, src);
|
||||
c_start = scm_to_size_t (start);
|
||||
c_count = scm_to_size_t (count);
|
||||
SCM_ASSERT_RANGE (2, start, c_start <= c_count);
|
||||
SCM_ASSERT_RANGE (3, count, c_start+c_count <= scm_c_bytevector_length (src));
|
||||
SCM_ASSERT_RANGE (3, start, c_start <= SCM_BYTEVECTOR_LENGTH (src));
|
||||
SCM_ASSERT_RANGE (4, count, c_count <= SCM_BYTEVECTOR_LENGTH (src) - c_start);
|
||||
|
||||
ret = SCM_PORT_TYPE (port)->c_write (port, src, c_start, c_count);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue