* socket.c (scm_fill_sockaddr): don't allow buffer overflows when
authorGary Houston <ghouston@arglist.com>
Sun, 4 Mar 2001 23:34:16 +0000 (23:34 +0000)
committerGary Houston <ghouston@arglist.com>
Sun, 4 Mar 2001 23:34:16 +0000 (23:34 +0000)
commit439006bf6e35ca2230e280755bc370fba85e01f3
tree28d050a4b3a081682a212913d81af98fe2902a9d
parent276dd6775cbb0fef46a7e75d3c004c4db1590703
* socket.c (scm_fill_sockaddr): don't allow buffer overflows when
taking an unexpectedly large filename for an AF_UNIX socket from
bind/connect/sendto (thanks to Martin Grabmueller).

* socket.c (scm_sock_fd_to_port, SCM_SOCK_FD_TO_PORT): removed the
former and adjusted the latter.
(scm_socket, scm_socketpair): cosmetic changes.
(scm_getsockopt, scm_setsockopt): declare optlen as int, not
size_t as socklen_t substitute.  don't restrict args/return values
to INUM: allow full range of int or size_t.
(scm_fill_sockaddr): check arguments before allocating memory, to
avoid leakage.  use malloc, not scm_must_malloc.
(scm_connect, scm_bind, scm_sendto): use int, not size_t as socklen_t
substitute.  free the sockaddr structure before throwing an error.
(scm_init_add_buffer): procedure removed, together with its static
buffer scm_addr_buffer, which wouldn't be thread safe.  instead,
define a macro MAX_ADDR_SIZE and declare the buffer where needed.
(scm_accept, scm_getpeername, scm_getsockname, scm_recvfrom,
scm_sendto): use a local buffer instead of scm_addr_buffer.
adjust for new SCM_SOCK_FD_TO_PORT.  use int for address size,
not size_t.
(scm_recvfrom): set addr->sa_family to AF_UNSPEC before the recvfrom
call to detect whether recvfrom could be bothered to set the address.
(scm_init_socket): don't call scm_init_addr_buffer.
libguile/ChangeLog
libguile/socket.c