>From f386bc4f580a09e54851f0cccccf5f213e831810 Mon Sep 17 00:00:00 2001 From: Peter Bex Date: Thu, 6 Feb 2014 10:00:17 +0100 Subject: [PATCH 2/2] Fix strlcat usage in setenv: use the start of the string as dest buffer and append the "=" using strlcat instead of overwriting the NUL character. --- posix-common.scm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/posix-common.scm b/posix-common.scm index 3911b07..93884de 100644 --- a/posix-common.scm +++ b/posix-common.scm @@ -101,7 +101,7 @@ static char C_time_string [TIME_STRING_MAXLENGTH + 1]; # define C_setenv(x, y) C_fix(setenv((char *)C_data_pointer(x), (char *)C_data_pointer(y), 1)) #else # if defined(_WIN32) && !defined(__CYGWIN__) -# define C_unsetenv(s) C_fix(C_setenv(s, C_SCHEME_FALSE)) +# define C_unsetenv(s) C_setenv(s, C_SCHEME_FALSE) # else # define C_unsetenv(s) C_fix(putenv((char *)C_data_pointer(s))) # endif @@ -114,8 +114,8 @@ static C_word C_fcall C_setenv(C_word x, C_word y) { if(buf == NULL) return(C_fix(0)); else { C_strlcpy(buf, sx, buf_len); - buf[ n1 ] = '='; - C_strlcat(buf + n1 + 1, sy, buf_len); + C_strlcat(buf, "=", buf_len); + C_strlcat(buf, sy, buf_len); return(C_fix(putenv(buf))); } } -- 1.7.10.4