mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-07-09 10:50:27 +02:00
Fix bounds check in recvfrom!
Closes https://debbugs.gnu.org/cgi/bugreport.cgi?bug=45595. NB: Amended by the committer to allow an empty range. * libguile/socket.c: As stated.
This commit is contained in:
parent
c5f443de79
commit
1a8294f495
1 changed files with 10 additions and 7 deletions
|
@ -1491,21 +1491,24 @@ SCM_DEFINE (scm_recvfrom, "recvfrom!", 2, 3, 0,
|
||||||
|
|
||||||
SCM_VALIDATE_BYTEVECTOR (1, buf);
|
SCM_VALIDATE_BYTEVECTOR (1, buf);
|
||||||
|
|
||||||
if (SCM_UNBNDP (start))
|
|
||||||
offset = 0;
|
|
||||||
else
|
|
||||||
offset = scm_to_size_t (start);
|
|
||||||
|
|
||||||
if (SCM_UNBNDP (end))
|
if (SCM_UNBNDP (end))
|
||||||
cend = SCM_BYTEVECTOR_LENGTH (buf);
|
cend = SCM_BYTEVECTOR_LENGTH (buf);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cend = scm_to_size_t (end);
|
cend = scm_to_size_t (end);
|
||||||
if (SCM_UNLIKELY (cend >= SCM_BYTEVECTOR_LENGTH (buf)
|
if (SCM_UNLIKELY (cend > SCM_BYTEVECTOR_LENGTH (buf)))
|
||||||
|| cend < offset))
|
|
||||||
scm_out_of_range (FUNC_NAME, end);
|
scm_out_of_range (FUNC_NAME, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SCM_UNBNDP (start))
|
||||||
|
offset = 0;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
offset = scm_to_size_t (start);
|
||||||
|
if (SCM_UNLIKELY (cend < offset))
|
||||||
|
scm_out_of_range (FUNC_NAME, start);
|
||||||
|
}
|
||||||
|
|
||||||
SCM_SYSCALL (rv = recvfrom (fd,
|
SCM_SYSCALL (rv = recvfrom (fd,
|
||||||
SCM_BYTEVECTOR_CONTENTS (buf) + offset,
|
SCM_BYTEVECTOR_CONTENTS (buf) + offset,
|
||||||
cend - offset, flg,
|
cend - offset, flg,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue