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,13 +199,17 @@
(error "bind-socket: socket-address expected ~s" name)) (error "bind-socket: socket-address expected ~s" name))
(else (else
(let ((family (socket:family sock))) (let ((family (socket:family sock)))
(if (not (= family (socket-address:family name))) (cond ((not (= family (socket-address:family name)))
(error (error
"bind-socket: trying to bind incompatible address to socket ~s" "bind-socket: trying to bind incompatible address to socket ~s"
name) name))
(%bind (socket->fdes sock) ((and (= family address-family/unix)
family (> (string-length name) 107))
(socket-address:address name))))))) (error "bind-socket: path too long" name))
(else
%bind (socket->fdes sock)
family
(socket-address:address name)))))))
(import-os-error-syscall %bind (sockfd family name) "scheme_bind") (import-os-error-syscall %bind (sockfd family name) "scheme_bind")

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)); memset(&name, 0, sizeof(name));
name.sun_family=AF_UNIX; 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, strncpy(name.sun_path,
s48_extract_string(scheme_name), s48_extract_string(scheme_name),
scheme_length); /* copy to c string */ scheme_length); /* copy to c string */