Check string-length of bind-socket in Scheme.

This commit is contained in:
mainzelm 2001-09-17 18:23:30 +00:00
parent 925ca7b349
commit a2eb80d3fe
2 changed files with 12 additions and 9 deletions

View File

@ -199,11 +199,15 @@
(error "bind-socket: socket-address expected ~s" name))
(else
(let ((family (socket:family sock)))
(if (not (= family (socket-address:family name)))
(cond ((not (= family (socket-address:family name)))
(error
"bind-socket: trying to bind incompatible address to socket ~s"
name)
(%bind (socket->fdes sock)
name))
((and (= family address-family/unix)
(> (string-length name) 107))
(error "bind-socket: path too long" name))
(else
%bind (socket->fdes sock)
family
(socket-address:address name)))))))

View File

@ -45,8 +45,7 @@ s48_value scheme_bind(s48_value sock, s48_value family, s48_value scheme_name)
memset(&name, 0, sizeof(name));
name.sun_family=AF_UNIX;
if (scheme_length>=(108-1)) /* save space for \0 */
return(-1); // TODO: check this in scheme !
strncpy(name.sun_path,
s48_extract_string(scheme_name),
scheme_length); /* copy to c string */