From 76a255ebcd910d758b45e665f6ea6a31139b27ac Mon Sep 17 00:00:00 2001 From: Peter Bex Date: Sat, 24 Nov 2018 12:30:08 +0100 Subject: [PATCH] Change definition of "link", "chroot" and "C_getenv" from c-string to nonnull-c-string to fix C compiler warnings In file-link and set-root-directory! we already checked the argument for being a string. In get-environment we did not do that, which meant #f would be passed to getenv() directly, causing a segfault. --- NEWS | 7 +++++++ library.scm | 2 +- posixunix.scm | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 18eefd7f..5eb7c803 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,10 @@ +5.0.1 + +- Core libraries + - Fix get-environment from (chicken process-context) to raise an + error when passed #f instead of segfaulting. + + 5.0.0 - Runtime system diff --git a/library.scm b/library.scm index 72d32150..d11bd7f5 100644 --- a/library.scm +++ b/library.scm @@ -5971,7 +5971,7 @@ static C_word C_fcall C_setenv(C_word x, C_word y) { ;;; Environment access: (define get-environment-variable - (foreign-lambda c-string "C_getenv" c-string)) + (foreign-lambda c-string "C_getenv" nonnull-c-string)) (define (set-environment-variable! var val) (##sys#check-string var 'set-environment-variable!) diff --git a/posixunix.scm b/posixunix.scm index e569ce97..a85f9dce 100644 --- a/posixunix.scm +++ b/posixunix.scm @@ -771,7 +771,7 @@ static int set_file_mtime(char *filename, C_word atime, C_word mtime) (##sys#read-symbolic-link fname 'read-symbolic-link)))) (set! chicken.file.posix#file-link - (let ([link (foreign-lambda int "link" c-string c-string)]) + (let ((link (foreign-lambda int "link" nonnull-c-string nonnull-c-string))) (lambda (old new) (##sys#check-string old 'file-link) (##sys#check-string new 'file-link) @@ -1284,7 +1284,7 @@ static int set_file_mtime(char *filename, C_word atime, C_word mtime) ;;; chroot: (set! chicken.process-context.posix#set-root-directory! - (let ([chroot (foreign-lambda int "chroot" c-string)]) + (let ((chroot (foreign-lambda int "chroot" nonnull-c-string))) (lambda (dir) (##sys#check-string dir 'set-root-directory!) (when (fx< (chroot dir) 0) -- 2.11.0