From: Andreas Fuchs Date: Thu, 26 Jan 2006 23:29:07 +0000 (+0000) Subject: 0.9.9.4: X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=5eb1bc45f5bd68638ae861dd8bd81c33ae6cd14d;p=sbcl.git 0.9.9.4: Fix memory fault in sb-bsd-sockets:get-protocol-by-name. Patch by Stelian Ionescu, sbcl-devel 2006-01-22. * Also export unsupported-protocol condition * Add 3 test cases. --- diff --git a/contrib/sb-bsd-sockets/defpackage.lisp b/contrib/sb-bsd-sockets/defpackage.lisp index fbd9bd9..f6d18b4 100644 --- a/contrib/sb-bsd-sockets/defpackage.lisp +++ b/contrib/sb-bsd-sockets/defpackage.lisp @@ -50,6 +50,8 @@ try-again-error no-recovery-error + unknown-protocol + ;; all socket options are also exported, by code in ;; sockopt.lisp diff --git a/contrib/sb-bsd-sockets/inet.lisp b/contrib/sb-bsd-sockets/inet.lisp index 4cc0684..5879341 100644 --- a/contrib/sb-bsd-sockets/inet.lisp +++ b/contrib/sb-bsd-sockets/inet.lisp @@ -27,6 +27,13 @@ Examples: #'parse-integer (split dotted-quads nil '(#\.)))) +(define-condition unknown-protocol () + ((name :initarg :name + :reader unknown-protocol-name)) + (:report (lambda (c s) + (format s "Protocol not found: ~a" (prin1-to-string + (unknown-protocol-name c)))))) + ;;; getprotobyname only works in the internet domain, which is why this ;;; is here (defun get-protocol-by-name (name) ;exported @@ -35,6 +42,8 @@ using getprotobyname(2) which typically looks in NIS or /etc/protocols" ;; for extra brownie points, could return canonical protocol name ;; and aliases as extra values (let ((ent (sockint::getprotobyname name))) + (if (sb-grovel::foreign-nullp ent) + (error 'unknown-protocol :name name)) (sockint::protoent-proto ent))) ;;; our protocol provides make-sockaddr-for, size-of-sockaddr, diff --git a/contrib/sb-bsd-sockets/tests.lisp b/contrib/sb-bsd-sockets/tests.lisp index 72ec0f2..c9954b5 100644 --- a/contrib/sb-bsd-sockets/tests.lisp +++ b/contrib/sb-bsd-sockets/tests.lisp @@ -12,6 +12,22 @@ (equalp (make-inet-address "242.1.211.3") #(242 1 211 3)) t) +(deftest get-protocol-by-name/tcp + (integerp (get-protocol-by-name "tcp")) + t) + +(deftest get-protocol-by-name/udp + (integerp (get-protocol-by-name "udp")) + t) + +(deftest get-protocol-by-name/error + (handler-case (get-protocol-by-name "nonexistent-protocol") + (unknown-protocol () + t) + (:no-error () + nil)) + t) + (deftest make-inet-socket ;; make a socket (let ((s (make-instance 'inet-socket :type :stream :protocol (get-protocol-by-name "tcp")))) diff --git a/version.lisp-expr b/version.lisp-expr index 67d4007..2867670 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -17,4 +17,4 @@ ;;; checkins which aren't released. (And occasionally for internal ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"0.9.9.3" +"0.9.9.4"