Raymond Toy pushed to branch master at cmucl / cmucl

Commits:

2 changed files:

Changes:

  • src/code/unix.lisp
    ... ... @@ -2748,9 +2748,12 @@
    2748 2748
     
    
    2749 2749
     #+linux
    
    2750 2750
     (defun unix-getpwuid (uid)
    
    2751
    -  _N"Return a USER-INFO structure for the user identified by UID, or NIL if not found."
    
    2751
    +  "Return a USER-INFO structure for the user identified by UID.  If
    
    2752
    +  not found, NIL is returned with a second value indicating the cause
    
    2753
    +  of the failure.  In particular, if the second value is 0 (or
    
    2754
    +  ENONENT, ESRCH, EBADF, etc.), then the uid was not found."
    
    2752 2755
       (declare (type unix-uid uid))
    
    2753
    -  (with-alien ((buf (array c-call:char 1024))
    
    2756
    +  (with-alien ((buf (array c-call:char 16384))
    
    2754 2757
     	       (user-info (struct passwd))
    
    2755 2758
                    (result (* (struct passwd))))
    
    2756 2759
         (let ((returned
    
    ... ... @@ -2767,15 +2770,16 @@
    2767 2770
     	    (cast buf (* c-call:char))
    
    2768 2771
     	    1024
    
    2769 2772
                 (addr result))))
    
    2770
    -      (when (zerop returned)
    
    2771
    -        (make-user-info
    
    2772
    -         :name (string (cast (slot result 'pw-name) c-call:c-string))
    
    2773
    -         :password (string (cast (slot result 'pw-passwd) c-call:c-string))
    
    2774
    -         :uid (slot result 'pw-uid)
    
    2775
    -         :gid (slot result 'pw-gid)
    
    2776
    -         :gecos (string (cast (slot result 'pw-gecos) c-call:c-string))
    
    2777
    -         :dir (string (cast (slot result 'pw-dir) c-call:c-string))
    
    2778
    -         :shell (string (cast (slot result 'pw-shell) c-call:c-string)))))))
    
    2773
    +      (if (not (zerop (sap-int (alien-sap result))))
    
    2774
    +          (make-user-info
    
    2775
    +           :name (string (cast (slot result 'pw-name) c-call:c-string))
    
    2776
    +           :password (string (cast (slot result 'pw-passwd) c-call:c-string))
    
    2777
    +           :uid (slot result 'pw-uid)
    
    2778
    +           :gid (slot result 'pw-gid)
    
    2779
    +           :gecos (string (cast (slot result 'pw-gecos) c-call:c-string))
    
    2780
    +           :dir (string (cast (slot result 'pw-dir) c-call:c-string))
    
    2781
    +           :shell (string (cast (slot result 'pw-shell) c-call:c-string)))
    
    2782
    +	  (values nil returned)))))
    
    2779 2783
     
    
    2780 2784
     ;;; Getrusage is not provided in the C library on Solaris 2.4, and is
    
    2781 2785
     ;;; rather slow on later versions so the "times" system call is
    

  • tests/issues.lisp
    ... ... @@ -570,3 +570,12 @@
    570 570
                  (terpri s)
    
    571 571
                  (fresh-line s))
    
    572 572
                a)))
    
    573
    +
    
    574
    +(define-test issue.127
    
    575
    +    (:tag :issues)
    
    576
    +  ;; Let's just start at uid 10000 and keep going up until we fail.
    
    577
    +  ;; There should be no segfaults when we find an invalid uid.
    
    578
    +  (loop for uid from 10000
    
    579
    +	with user-info = (unix:unix-getpwuid uid)
    
    580
    +	while user-info
    
    581
    +	finally (assert-false user-info)))