GNU bug report logs - #45595
recvfrom! optional start and end parameter invalid

Previous Next

Package: guile;

Reported by: d4ryus <d4ryus <at> mailbox.org>

Date: Fri, 1 Jan 2021 14:59:02 UTC

Severity: normal

Done: lloda <lloda <at> sarc.name>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: d4ryus <d4ryus <at> mailbox.org>
Subject: bug#45595: closed (Re: recvfrom! optional start and end parameter
 invalid)
Date: Wed, 03 Nov 2021 18:30:03 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#45595: recvfrom! optional start and end parameter invalid

which was filed against the guile package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 45595 <at> debbugs.gnu.org.

-- 
45595: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=45595
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: lloda <lloda <at> sarc.name>
To: 45595-done <at> debbugs.gnu.org
Subject: Re: recvfrom! optional start and end parameter invalid
Date: Wed, 3 Nov 2021 19:29:03 +0100
Hi,

Your patch didn't allow for start == end, which is valid as far as I can tell.

With that amended, applied in 1a8294f495cb202f8fcd0f260627c58e7a4c4d10. Thanks!



[Message part 3 (message/rfc822, inline)]
From: d4ryus <d4ryus <at> mailbox.org>
To: bug-guile <at> gnu.org
Subject: recvfrom! optional start and end parameter invalid
Date: Fri, 1 Jan 2021 12:34:57 +0100
[Message part 4 (text/plain, inline)]
hi,

the parameter validation for the optional "start" and "end" arguments to
"recvfrom!" are off by one if "end" is passed. From libguile/socket.c
(master commit 64c89458e6):

  ...
  if (SCM_UNBNDP (end))
    cend = SCM_BYTEVECTOR_LENGTH (buf);
  else
    {
      cend = scm_to_size_t (end);
      if (SCM_UNLIKELY (cend >= SCM_BYTEVECTOR_LENGTH (buf)
                        || cend < offset))
        scm_out_of_range (FUNC_NAME, end);
    }
  ...

"end" is the optional end argument, "offset" is 0 or "start" if start
was given. The check must be:

  cend > SCM_BYTEVECTOR_LENGTH (buf) || cend <= offset

to allow filling the last byte in the buffer and verify that start is
not equal to end. A workaround to skip the validation is to not pass
end. But i think a better way would be to always validate start (and
end), if one (or both) of them are passed. A potentional fix is
attached.

If you need any additional information, please let me know.

Thank you for your great work!

-  d4ryus
[recvfrom-fix.patch (text/plain, attachment)]

This bug report was last modified 3 years and 283 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.