From a2eb80d3fed74543d0810307f5262ec721d85291 Mon Sep 17 00:00:00 2001 From: mainzelm Date: Mon, 17 Sep 2001 18:23:30 +0000 Subject: [PATCH] Check string-length of bind-socket in Scheme. --- scsh/network.scm | 18 +++++++++++------- scsh/network1.c | 3 +-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/scsh/network.scm b/scsh/network.scm index df4c102..73775c0 100644 --- a/scsh/network.scm +++ b/scsh/network.scm @@ -199,13 +199,17 @@ (error "bind-socket: socket-address expected ~s" name)) (else (let ((family (socket:family sock))) - (if (not (= family (socket-address:family name))) - (error - "bind-socket: trying to bind incompatible address to socket ~s" - name) - (%bind (socket->fdes sock) - family - (socket-address:address name))))))) + (cond ((not (= family (socket-address:family name))) + (error + "bind-socket: trying to bind incompatible address to socket ~s" + 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))))))) (import-os-error-syscall %bind (sockfd family name) "scheme_bind") diff --git a/scsh/network1.c b/scsh/network1.c index 3f599f8..7206708 100644 --- a/scsh/network1.c +++ b/scsh/network1.c @@ -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 */