Changeset 27256 in project


Ignore:
Timestamp:
08/17/12 05:35:50 (9 years ago)
Author:
Jim Ursetto
Message:

socket 0.2.2: socket-receive, socket-send and friends must typecheck socket arg; fixes segfault (reported by hypnocat)

Location:
release/4/socket/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/4/socket/trunk/socket.scm

    r26915 r27256  
    567567(define-inline (%socket-fileno so)
    568568  (##sys#slot so 1))
     569(define-inline (check-socket so loc)
     570  (unless (socket? so)
     571    (type-error loc "argument is not a socket" so)))
    569572
    570573(define-record-printer (socket s out)
     
    754757                                       "receive buffer must be a blob or a string" so))))
    755758         (end (or end buflen)))
     759    (check-socket so 'socket-receive!)
    756760    (##sys#check-exact start)   
    757761    (##sys#check-exact end)
     
    786790;; TODO: Should LEN default to socket-receive-buffer-size ?
    787791(define (socket-receive so len #!optional (flags 0))
    788   (let ((buf (make-string len)))
     792  (let ((buf (make-string len)))  ; checks len exact
     793    (check-socket so 'socket-receive)
     794    (##sys#check-exact flags)
    789795    (let ((n (%socket-receive! so buf 0 len flags (socket-receive-timeout))))
    790796      (if (= len n)
     
    803809                                       "receive buffer must be a blob or a string" so))))
    804810         (end (or end buflen)))
     811    (check-socket so 'socket-receive-from!)
    805812    (##sys#check-exact start)   
    806813    (##sys#check-exact end)
     
    858865;; See TODOs at socket-receive.
    859866(define (socket-receive-from so len #!optional (flags 0))
    860   (let ((buf (make-string len)))
     867  (let ((buf (make-string len))) ; checks len exact
     868    (check-socket so 'socket-receive-from)
     869    (##sys#check-exact flags)
    861870    (let ((R (%socket-receive-from! so buf 0 len flags (socket-receive-timeout))))
    862871      (let ((n (car R)))
     
    878887                                       "send buffer must be a blob or a string" so))))
    879888         (end (or end buflen)))
     889    (check-socket so 'socket-send)
    880890    (##sys#check-exact start)
    881891    (##sys#check-exact end)
     
    928938                                       "send buffer must be a blob or a string" so))))
    929939         (end (or end buflen)))
     940    (check-socket so 'socket-send-all)
    930941    (##sys#check-exact start)
    931942    (##sys#check-exact end)
     
    948959                                       "send buffer must be a blob or a string" so))))
    949960         (end (or end buflen)))
     961    (check-socket so 'socket-send-to)
    950962    (##sys#check-exact start)
    951963    (##sys#check-exact end)
  • release/4/socket/trunk/socket.setup

    r26915 r27256  
    99 'socket
    1010 '("socket.so" "socket.import.so")
    11  '((version "0.2.1")))
     11 '((version "0.2.2")))
Note: See TracChangeset for help on using the changeset viewer.