Raymond Toy pushed to branch master at cmucl / cmucl
Commits:
88ca0184 by Raymond Toy at 2022-08-08T10:44:47-07:00
Update release notes
We've fixed bugs #122 and #127 now, so make a note of it.
- - - - -
1 changed file:
- src/general-info/release-21e.md
Changes:
=====================================
src/general-info/release-21e.md
=====================================
@@ -49,6 +49,8 @@ public domain.
* ~~#112~~ CLX can't connect to X server via inet sockets
* ~~#113~~ REQUIRE on contribs can pull in the wrong things vai ASDF.
* ~~#121~~ Wrong column index in FILL-POINTER-OUTPUT-STREAM
+ * ~~#122~~ gcc 11 can't build cmucl
+ * ~~#127~~ Linux unix-getpwuid segfaults when given non-existent uid.
* Other changes:
* Improvements to the PCL implementation of CLOS:
* Changes to building procedure:
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/88ca0184f219100c92888cf…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/88ca0184f219100c92888cf…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch master at cmucl / cmucl
Commits:
1af344b3 by Raymond Toy at 2022-08-08T17:39:43+00:00
Fix #127: Linux unix:unix-getpwuid segfaults with invalid uid
- - - - -
9bba5bc4 by Raymond Toy at 2022-08-08T17:39:45+00:00
Merge branch 'issue-127-getpwuid-segfault' into 'master'
Fix #127: Linux unix:unix-getpwuid segfaults with invalid uid
Closes #127
See merge request cmucl/cmucl!86
- - - - -
2 changed files:
- src/code/unix.lisp
- tests/issues.lisp
Changes:
=====================================
src/code/unix.lisp
=====================================
@@ -2748,9 +2748,12 @@
#+linux
(defun unix-getpwuid (uid)
- _N"Return a USER-INFO structure for the user identified by UID, or NIL if not found."
+ "Return a USER-INFO structure for the user identified by UID. If
+ not found, NIL is returned with a second value indicating the cause
+ of the failure. In particular, if the second value is 0 (or
+ ENONENT, ESRCH, EBADF, etc.), then the uid was not found."
(declare (type unix-uid uid))
- (with-alien ((buf (array c-call:char 1024))
+ (with-alien ((buf (array c-call:char 16384))
(user-info (struct passwd))
(result (* (struct passwd))))
(let ((returned
@@ -2767,15 +2770,16 @@
(cast buf (* c-call:char))
1024
(addr result))))
- (when (zerop returned)
- (make-user-info
- :name (string (cast (slot result 'pw-name) c-call:c-string))
- :password (string (cast (slot result 'pw-passwd) c-call:c-string))
- :uid (slot result 'pw-uid)
- :gid (slot result 'pw-gid)
- :gecos (string (cast (slot result 'pw-gecos) c-call:c-string))
- :dir (string (cast (slot result 'pw-dir) c-call:c-string))
- :shell (string (cast (slot result 'pw-shell) c-call:c-string)))))))
+ (if (not (zerop (sap-int (alien-sap result))))
+ (make-user-info
+ :name (string (cast (slot result 'pw-name) c-call:c-string))
+ :password (string (cast (slot result 'pw-passwd) c-call:c-string))
+ :uid (slot result 'pw-uid)
+ :gid (slot result 'pw-gid)
+ :gecos (string (cast (slot result 'pw-gecos) c-call:c-string))
+ :dir (string (cast (slot result 'pw-dir) c-call:c-string))
+ :shell (string (cast (slot result 'pw-shell) c-call:c-string)))
+ (values nil returned)))))
;;; Getrusage is not provided in the C library on Solaris 2.4, and is
;;; rather slow on later versions so the "times" system call is
=====================================
tests/issues.lisp
=====================================
@@ -570,3 +570,12 @@
(terpri s)
(fresh-line s))
a)))
+
+(define-test issue.127
+ (:tag :issues)
+ ;; Let's just start at uid 10000 and keep going up until we fail.
+ ;; There should be no segfaults when we find an invalid uid.
+ (loop for uid from 10000
+ with user-info = (unix:unix-getpwuid uid)
+ while user-info
+ finally (assert-false user-info)))
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/00907500388dcbabd11306…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/00907500388dcbabd11306…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch issue-125-unix-stat-wrong at cmucl / cmucl
Commits:
750c109a by Raymond Toy at 2022-08-04T07:36:39-07:00
Remove solaris versions of stat and friends
This has been replaced by unix_stat and friends.
- - - - -
1 changed file:
- src/code/unix.lisp
Changes:
=====================================
src/code/unix.lisp
=====================================
@@ -1467,42 +1467,6 @@
(declare (type unix-fd fd))
(call-stat "unix_fstat" int fd)))
-;;; 64-bit versions of stat and friends
-#+solaris
-(progn
-(defun unix-stat (name)
- _N"Unix-stat retrieves information about the specified
- file returning them in the form of multiple values.
- See the UNIX Programmer's Manual for a description
- of the values returned. If the call fails, then NIL
- and an error number is returned instead."
- (declare (type unix-pathname name))
- (when (string= name "")
- (setf name "."))
- (with-alien ((buf (struct stat64)))
- (syscall ("stat64" c-string (* (struct stat64)))
- (extract-stat-results buf)
- (%name->file name) (addr buf))))
-
-(defun unix-lstat (name)
- _N"Unix-lstat is similar to unix-stat except the specified
- file must be a symbolic link."
- (declare (type unix-pathname name))
- (with-alien ((buf (struct stat64)))
- (syscall ("lstat64" c-string (* (struct stat64)))
- (extract-stat-results buf)
- (%name->file name) (addr buf))))
-
-(defun unix-fstat (fd)
- _N"Unix-fstat is similar to unix-stat except the file is specified
- by the file descriptor fd."
- (declare (type unix-fd fd))
- (with-alien ((buf (struct stat64)))
- (syscall ("fstat64" int (* (struct stat64)))
- (extract-stat-results buf)
- fd (addr buf))))
-)
-
(def-alien-type nil
(struct rusage
(ru-utime (struct timeval)) ; user time used
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/750c109add317988cdb319e…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/750c109add317988cdb319e…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch issue-125-unix-stat-wrong at cmucl / cmucl
Commits:
a831003a by Raymond Toy at 2022-08-04T07:18:22-07:00
Update POT file for new docstrings for stat
- - - - -
1 changed file:
- src/i18n/locale/cmucl-unix.pot
Changes:
=====================================
src/i18n/locale/cmucl-unix.pot
=====================================
@@ -486,6 +486,76 @@ msgstr ""
msgid "Size of control character vector."
msgstr ""
+#: src/code/unix.lisp
+msgid ""
+"Unix-stat retrieves information about the specified\n"
+" file returning them in the form of multiple values. If the call\n"
+" fails, then NIL and an error number is returned. If the call\n"
+" succeeds, then T is returned in addition to the following values\n"
+" from the stat struct st:\n"
+"\n"
+" st_dev Device ID\n"
+" st_ino File serial number\n"
+" st_mode Mode of file\n"
+" st_nlink Number of hard links to the file\n"
+" st_uid User ID\n"
+" st_gid Group ID\n"
+" st_rdev Device ID (if file is character or block special)\n"
+" st_atime Last data access time, in sec\n"
+" st_mtime Last data modification time, in sec\n"
+" st_ctime Last file status change time, in sec\n"
+" st_blksize Preferred I/O block size\n"
+" st_blocks Number of blocks allocated. (Block size is implementation"
+" dependent.)\n"
+""
+msgstr ""
+
+#: src/code/unix.lisp
+msgid ""
+"Unix-fstat is similar to unix-stat except the file is specified\n"
+" by the file descriptor fd. If the call fails, then NIL and an\n"
+" error number is returned. If the call succeeds, then T is returned\n"
+" in addition to the following values from the stat struct st:\n"
+"\n"
+" st_dev Device ID\n"
+" st_ino File serial number\n"
+" st_mode Mode of file\n"
+" st_nlink Number of hard links to the file\n"
+" st_uid User ID\n"
+" st_gid Group ID\n"
+" st_rdev Device ID (if file is character or block special)\n"
+" st_atime Last data access time, in sec\n"
+" st_mtime Last data modification time, in sec\n"
+" st_ctime Last file status change time, in sec\n"
+" st_blksize Preferred I/O block size\n"
+" st_blocks Number of blocks allocated. (Block size is implementation"
+" dependent.)\n"
+""
+msgstr ""
+
+#: src/code/unix.lisp
+msgid ""
+"Unix-lstat is similar to unix-stat except the specified\n"
+" file must be a symbolic link. If the call fails, then NIL and an\n"
+" error number is returned. If the call succeeds, then T is returned\n"
+" in addition to the following values from the stat struct st:\n"
+"\n"
+" st_dev Device ID\n"
+" st_ino File serial number\n"
+" st_mode Mode of file\n"
+" st_nlink Number of hard links to the file\n"
+" st_uid User ID\n"
+" st_gid Group ID\n"
+" st_rdev Device ID (if file is character or block special)\n"
+" st_atime Last data access time, in sec\n"
+" st_mtime Last data modification time, in sec\n"
+" st_ctime Last file status change time, in sec\n"
+" st_blksize Preferred I/O block size\n"
+" st_blocks Number of blocks allocated. (Block size is implementation"
+" dependent.)\n"
+""
+msgstr ""
+
#: src/code/unix.lisp
msgid ""
"Unix-stat retrieves information about the specified\n"
@@ -497,14 +567,14 @@ msgstr ""
#: src/code/unix.lisp
msgid ""
-"Unix-fstat is similar to unix-stat except the file is specified\n"
-" by the file descriptor fd."
+"Unix-lstat is similar to unix-stat except the specified\n"
+" file must be a symbolic link."
msgstr ""
#: src/code/unix.lisp
msgid ""
-"Unix-lstat is similar to unix-stat except the specified\n"
-" file must be a symbolic link."
+"Unix-fstat is similar to unix-stat except the file is specified\n"
+" by the file descriptor fd."
msgstr ""
#: src/code/unix.lisp
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/a831003a17f8c31c2e96d41…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/a831003a17f8c31c2e96d41…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch issue-125-unix-stat-wrong at cmucl / cmucl
Commits:
c36ad0c7 by Raymond Toy at 2022-08-03T19:53:21-07:00
Remove unused alien types and update docstrings
The alien types dev-t and nlink-t aren't used anywhere anymore so
remove them.
Update the docstrings for unix-stat and friends to describe what the
multiple return values are.
- - - - -
1 changed file:
- src/code/unix.lisp
Changes:
=====================================
src/code/unix.lisp
=====================================
@@ -69,14 +69,6 @@
#+(and bsd netbsd) int64-t
#+alpha unsigned-int)
-#+nil
-(def-alien-type dev-t
- #-(or alpha svr4 bsd linux) short
- #+linux u-int64-t
- #+netbsd u-int64-t
- #+alpha int
- #+(and (not linux) (not netbsd) (or bsd svr4)) unsigned-long)
-
#-BSD
(progn
(deftype file-offset () '(signed-byte 32))
@@ -128,13 +120,6 @@
`(multiple-value-bind (,word ,bit) (floor ,offset 32)
(logbitp ,bit (deref (slot ,fd-set 'fds-bits) ,word)))))
-(def-alien-type nlink-t
- #-(or svr4 netbsd linux) unsigned-short
- #+netbsd unsigned-long
- #+svr4 unsigned-long
- #+(and linux (not amd64)) unsigned-int
- #+(and linux amd64) u-int64-t)
-
(defconstant fd-setsize
#-(or hpux alpha linux FreeBSD) 256
#+hpux 2048 #+alpha 4096 #+(or linux FreeBSD) 1024)
@@ -1415,10 +1400,24 @@
blocks))))))
(defun unix-stat (name)
_N"Unix-stat retrieves information about the specified
- file returning them in the form of multiple values.
- See the UNIX Programmer's Manual for a description
- of the values returned. If the call fails, then NIL
- and an error number is returned instead."
+ file returning them in the form of multiple values. If the call
+ fails, then NIL and an error number is returned. If the call
+ succeeds, then T is returned in addition to the following values
+ from the stat struct st:
+
+ st_dev Device ID
+ st_ino File serial number
+ st_mode Mode of file
+ st_nlink Number of hard links to the file
+ st_uid User ID
+ st_gid Group ID
+ st_rdev Device ID (if file is character or block special)
+ st_atime Last data access time, in sec
+ st_mtime Last data modification time, in sec
+ st_ctime Last file status change time, in sec
+ st_blksize Preferred I/O block size
+ st_blocks Number of blocks allocated. (Block size is implementation dependent.)
+"
(declare (type unix-pathname name))
(when (string= name "")
(setf name "."))
@@ -1426,13 +1425,45 @@
(defun unix-lstat (name)
"Unix-lstat is similar to unix-stat except the specified
- file must be a symbolic link."
+ file must be a symbolic link. If the call fails, then NIL and an
+ error number is returned. If the call succeeds, then T is returned
+ in addition to the following values from the stat struct st:
+
+ st_dev Device ID
+ st_ino File serial number
+ st_mode Mode of file
+ st_nlink Number of hard links to the file
+ st_uid User ID
+ st_gid Group ID
+ st_rdev Device ID (if file is character or block special)
+ st_atime Last data access time, in sec
+ st_mtime Last data modification time, in sec
+ st_ctime Last file status change time, in sec
+ st_blksize Preferred I/O block size
+ st_blocks Number of blocks allocated. (Block size is implementation dependent.)
+"
(declare (type unix-pathname name))
(call-stat "unix_lstat" c-call:c-string (%name->file name)))
(defun unix-fstat (fd)
_N"Unix-fstat is similar to unix-stat except the file is specified
- by the file descriptor fd."
+ by the file descriptor fd. If the call fails, then NIL and an
+ error number is returned. If the call succeeds, then T is returned
+ in addition to the following values from the stat struct st:
+
+ st_dev Device ID
+ st_ino File serial number
+ st_mode Mode of file
+ st_nlink Number of hard links to the file
+ st_uid User ID
+ st_gid Group ID
+ st_rdev Device ID (if file is character or block special)
+ st_atime Last data access time, in sec
+ st_mtime Last data modification time, in sec
+ st_ctime Last file status change time, in sec
+ st_blksize Preferred I/O block size
+ st_blocks Number of blocks allocated. (Block size is implementation dependent.)
+"
(declare (type unix-fd fd))
(call-stat "unix_fstat" int fd)))
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/c36ad0c736ca2f037eddb83…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/c36ad0c736ca2f037eddb83…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch issue-125-unix-stat-wrong at cmucl / cmucl
Commits:
b726c5a4 by Raymond Toy at 2022-08-03T19:01:31-07:00
Don't use dev_t and friends in stat interface definition.
To simplify things, don't use dev_t and friends in the C interface.
Instead, use the largest integer type that any OS would want to use.
So dev_t becomes u_int64_t because Linux can return 64-bit integers
here. This would work just fine for macos which uses 32-bit integers.
We are depending on the compiler to produce a warning or error if we
try to store a larger integer type into a smaller type.
- - - - -
2 changed files:
- src/code/unix.lisp
- src/lisp/os-common.c
Changes:
=====================================
src/code/unix.lisp
=====================================
@@ -69,6 +69,7 @@
#+(and bsd netbsd) int64-t
#+alpha unsigned-int)
+#+nil
(def-alien-type dev-t
#-(or alpha svr4 bsd linux) short
#+linux u-int64-t
@@ -1351,37 +1352,37 @@
;; to the stat function. fstat is different from stat and
;; lstat since it takes an fd for the first arg instead of
;; string.
- `(with-alien ((dev dev-t)
- (ino ino-t)
- (mode mode-t)
- (nlink nlink-t)
- (uid uid-t)
- (gid gid-t)
- (rdev dev-t)
- (size off-t)
- (atime time-t)
- (mtime time-t)
- (ctime time-t)
+ `(with-alien ((dev u-int64-t)
+ (ino u-int64-t)
+ (mode c-call:unsigned-int)
+ (nlink u-int64-t)
+ (uid c-call:unsigned-int)
+ (gid c-call:unsigned-int)
+ (rdev u-int64-t)
+ (size int64-t)
+ (atime int64-t)
+ (mtime int64-t)
+ (ctime int64-t)
(blksize c-call:long)
- (blocks off-t))
+ (blocks int64-t))
(let ((result
(alien-funcall
(extern-alien ,c-func-name
(function int
,first-arg-type
- (* dev-t)
- (* ino-t)
- (* mode-t)
- (* nlink-t)
- (* uid-t)
- (* gid-t)
- (* dev-t)
- (* off-t)
- (* time-t)
- (* time-t)
- (* time-t)
+ (* u-int64-t)
+ (* u-int64-t)
+ (* c-call:unsigned-int)
+ (* u-int64-t)
+ (* c-call:unsigned-int)
+ (* c-call:unsigned-int)
+ (* u-int64-t)
+ (* int64-t)
+ (* int64-t)
+ (* int64-t)
+ (* int64-t)
(* c-call:long)
- (* off-t)))
+ (* int64-t)))
,first-arg
(addr dev)
(addr ino)
=====================================
src/lisp/os-common.c
=====================================
@@ -597,11 +597,19 @@ os_sleep(double seconds)
}
}
+/*
+ * Interface to stat/fstat/lstat.
+ *
+ * The arg types are chosen such that they can hold the largest
+ * possible value that any OS would use for the particular slot in the
+ * stat structure. That way we can just use one OS-independent
+ * function that works across all OSes.
+ */
int
-unix_stat(const char* path, dev_t *dev, ino_t *ino, mode_t *mode, nlink_t *nlink,
- uid_t *uid, gid_t *gid, dev_t *rdev, off_t *size,
- time_t *atime, time_t *mtime, time_t *ctime,
- long *blksize, off_t *blocks)
+unix_stat(const char* path, u_int64_t *dev, u_int64_t *ino, unsigned int *mode, u_int64_t *nlink,
+ unsigned int *uid, unsigned int *gid, u_int64_t *rdev, int64_t *size,
+ int64_t *atime, int64_t *mtime, int64_t *ctime,
+ long *blksize, int64_t *blocks)
{
int rc;
struct stat buf;
@@ -647,10 +655,10 @@ unix_stat(const char* path, dev_t *dev, ino_t *ino, mode_t *mode, nlink_t *nlink
}
int
-unix_fstat(int fd, dev_t *dev, ino_t *ino, mode_t *mode, nlink_t *nlink,
- uid_t *uid, gid_t *gid, dev_t *rdev, off_t *size,
- time_t *atime, time_t *mtime, time_t *ctime,
- long *blksize, off_t *blocks)
+unix_fstat(int fd, u_int64_t *dev, u_int64_t *ino, unsigned int *mode, u_int64_t *nlink,
+ unsigned int *uid, unsigned int *gid, u_int64_t *rdev, int64_t *size,
+ int64_t *atime, int64_t *mtime, int64_t *ctime,
+ long *blksize, int64_t *blocks)
{
int rc;
struct stat buf;
@@ -675,10 +683,10 @@ unix_fstat(int fd, dev_t *dev, ino_t *ino, mode_t *mode, nlink_t *nlink,
}
int
-unix_lstat(const char* path, dev_t *dev, ino_t *ino, mode_t *mode, nlink_t *nlink,
- uid_t *uid, gid_t *gid, dev_t *rdev, off_t *size,
- time_t *atime, time_t *mtime, time_t *ctime,
- long *blksize, off_t *blocks)
+unix_lstat(const char* path, u_int64_t *dev, u_int64_t *ino, unsigned int *mode, u_int64_t *nlink,
+ unsigned int *uid, unsigned int *gid, u_int64_t *rdev, int64_t *size,
+ int64_t *atime, int64_t *mtime, int64_t *ctime,
+ long *blksize, int64_t *blocks)
{
int rc;
struct stat buf;
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/b726c5a416dd05fc6fbd848…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/b726c5a416dd05fc6fbd848…
You're receiving this email because of your account on gitlab.common-lisp.net.