Add a whole bunch of S48_GC_PROTECT annotations in functions which
call s48_extract_integer. s48_extract_integer can cause a callback for bignums, and, hence, heap allocation. This fixes a bug report by Seth Alves <alves@hungry.com> noting spurious failures in SET-FILE-TIMES.
This commit is contained in:
parent
d30130ab03
commit
4381ac9095
173
scsh/syscalls1.c
173
scsh/syscalls1.c
|
@ -59,17 +59,21 @@ extern char **environ;
|
||||||
s48_value wait_pid(s48_value s48_pid, s48_value s48_flags)
|
s48_value wait_pid(s48_value s48_pid, s48_value s48_flags)
|
||||||
{
|
{
|
||||||
int status=0;
|
int status=0;
|
||||||
pid_t pid = (pid_t) s48_extract_integer (s48_pid);
|
pid_t pid;
|
||||||
int flags = s48_extract_integer (s48_flags);
|
int flags;
|
||||||
pid_t result_pid;
|
pid_t result_pid;
|
||||||
s48_value sch_retval = S48_UNSPECIFIC;
|
s48_value sch_retval = S48_UNSPECIFIC;
|
||||||
|
|
||||||
s48_value sch_result_pid = S48_UNSPECIFIC;
|
s48_value sch_result_pid = S48_UNSPECIFIC;
|
||||||
s48_value sch_status = S48_UNSPECIFIC;
|
s48_value sch_status = S48_UNSPECIFIC;
|
||||||
s48_value sch_status_list = S48_UNSPECIFIC;
|
s48_value sch_status_list = S48_UNSPECIFIC;
|
||||||
S48_DECLARE_GC_PROTECT(3);
|
S48_DECLARE_GC_PROTECT(5);
|
||||||
|
|
||||||
S48_GC_PROTECT_3(sch_result_pid, sch_status, sch_status_list);
|
S48_GC_PROTECT_5(s48_pid, s48_flags,
|
||||||
|
sch_result_pid, sch_status, sch_status_list);
|
||||||
|
|
||||||
|
pid = (pid_t) s48_extract_integer (s48_pid);
|
||||||
|
flags = s48_extract_integer (s48_flags);
|
||||||
|
|
||||||
result_pid = waitpid(pid, &status, flags);
|
result_pid = waitpid(pid, &status, flags);
|
||||||
if (result_pid == -1)
|
if (result_pid == -1)
|
||||||
|
@ -261,9 +265,16 @@ s48_value scm_utime(s48_value sch_path, s48_value sch_ac, s48_value sch_mod)
|
||||||
{
|
{
|
||||||
struct utimbuf t;
|
struct utimbuf t;
|
||||||
int retval;
|
int retval;
|
||||||
|
S48_DECLARE_GC_PROTECT(3);
|
||||||
|
|
||||||
|
S48_GC_PROTECT_3(sch_path, sch_ac, sch_mod);
|
||||||
|
|
||||||
t.actime = s48_extract_integer (sch_ac);
|
t.actime = s48_extract_integer (sch_ac);
|
||||||
t.modtime = s48_extract_integer (sch_mod);
|
t.modtime = s48_extract_integer (sch_mod);
|
||||||
retval = utime(s48_extract_string (sch_path), &t);
|
retval = utime(s48_extract_string (sch_path), &t);
|
||||||
|
|
||||||
|
S48_GC_UNPROTECT();
|
||||||
|
|
||||||
if (retval == -1)
|
if (retval == -1)
|
||||||
s48_raise_os_error_3(errno, sch_path, sch_ac, sch_mod);
|
s48_raise_os_error_3(errno, sch_path, sch_ac, sch_mod);
|
||||||
return S48_UNSPECIFIC;
|
return S48_UNSPECIFIC;
|
||||||
|
@ -409,8 +420,16 @@ s48_value cpu_clock_ticks_per_sec()
|
||||||
|
|
||||||
s48_value scsh_chmod(s48_value sch_path, s48_value sch_mode)
|
s48_value scsh_chmod(s48_value sch_path, s48_value sch_mode)
|
||||||
{
|
{
|
||||||
int retval = chmod (s48_extract_string(sch_path),
|
int retval;
|
||||||
|
S48_DECLARE_GC_PROTECT(2);
|
||||||
|
|
||||||
|
S48_GC_PROTECT_2(sch_path, sch_mode);
|
||||||
|
|
||||||
|
retval = chmod (s48_extract_string(sch_path),
|
||||||
s48_extract_integer(sch_mode));
|
s48_extract_integer(sch_mode));
|
||||||
|
|
||||||
|
S48_GC_UNPROTECT();
|
||||||
|
|
||||||
if (retval == -1)
|
if (retval == -1)
|
||||||
s48_raise_os_error_2(errno, sch_path, sch_mode);
|
s48_raise_os_error_2(errno, sch_path, sch_mode);
|
||||||
return S48_UNSPECIFIC;
|
return S48_UNSPECIFIC;
|
||||||
|
@ -418,8 +437,16 @@ s48_value scsh_chmod(s48_value sch_path, s48_value sch_mode)
|
||||||
|
|
||||||
s48_value scsh_fchmod(s48_value sch_fd, s48_value sch_mode)
|
s48_value scsh_fchmod(s48_value sch_fd, s48_value sch_mode)
|
||||||
{
|
{
|
||||||
int retval = fchmod (s48_extract_fixnum(sch_fd),
|
int retval;
|
||||||
|
S48_DECLARE_GC_PROTECT(2);
|
||||||
|
|
||||||
|
S48_GC_PROTECT_2(sch_fd, sch_mode);
|
||||||
|
|
||||||
|
retval = fchmod (s48_extract_fixnum(sch_fd),
|
||||||
s48_extract_integer(sch_mode));
|
s48_extract_integer(sch_mode));
|
||||||
|
|
||||||
|
S48_GC_UNPROTECT();
|
||||||
|
|
||||||
if (retval == -1)
|
if (retval == -1)
|
||||||
s48_raise_os_error_2(errno, sch_fd, sch_mode);
|
s48_raise_os_error_2(errno, sch_fd, sch_mode);
|
||||||
return S48_UNSPECIFIC;
|
return S48_UNSPECIFIC;
|
||||||
|
@ -427,10 +454,17 @@ s48_value scsh_fchmod(s48_value sch_fd, s48_value sch_mode)
|
||||||
|
|
||||||
s48_value scsh_chown(s48_value sch_path, s48_value sch_uid, s48_value sch_gid)
|
s48_value scsh_chown(s48_value sch_path, s48_value sch_uid, s48_value sch_gid)
|
||||||
{
|
{
|
||||||
int retval = chown(s48_extract_string(sch_path),
|
int retval;
|
||||||
|
S48_DECLARE_GC_PROTECT(3);
|
||||||
|
|
||||||
|
S48_GC_PROTECT_3(sch_path, sch_uid, sch_gid);
|
||||||
|
|
||||||
|
retval = chown(s48_extract_string(sch_path),
|
||||||
s48_extract_integer(sch_uid),
|
s48_extract_integer(sch_uid),
|
||||||
s48_extract_integer(sch_gid));
|
s48_extract_integer(sch_gid));
|
||||||
|
|
||||||
|
S48_GC_UNPROTECT();
|
||||||
|
|
||||||
if (retval == -1)
|
if (retval == -1)
|
||||||
s48_raise_os_error_3(errno, sch_path, sch_uid, sch_gid);
|
s48_raise_os_error_3(errno, sch_path, sch_uid, sch_gid);
|
||||||
return S48_UNSPECIFIC;
|
return S48_UNSPECIFIC;
|
||||||
|
@ -438,10 +472,17 @@ s48_value scsh_chown(s48_value sch_path, s48_value sch_uid, s48_value sch_gid)
|
||||||
|
|
||||||
s48_value scsh_fchown(s48_value sch_fd, s48_value sch_uid, s48_value sch_gid)
|
s48_value scsh_fchown(s48_value sch_fd, s48_value sch_uid, s48_value sch_gid)
|
||||||
{
|
{
|
||||||
int retval = fchown(s48_extract_fixnum(sch_fd),
|
int retval;
|
||||||
|
S48_DECLARE_GC_PROTECT(3);
|
||||||
|
|
||||||
|
S48_GC_PROTECT_3(sch_fd, sch_uid, sch_gid);
|
||||||
|
|
||||||
|
retval = fchown(s48_extract_fixnum(sch_fd),
|
||||||
s48_extract_integer(sch_uid),
|
s48_extract_integer(sch_uid),
|
||||||
s48_extract_integer(sch_gid));
|
s48_extract_integer(sch_gid));
|
||||||
|
|
||||||
|
S48_GC_UNPROTECT();
|
||||||
|
|
||||||
if (retval == -1)
|
if (retval == -1)
|
||||||
s48_raise_os_error_3(errno, sch_fd, sch_uid, sch_gid);
|
s48_raise_os_error_3(errno, sch_fd, sch_uid, sch_gid);
|
||||||
return S48_UNSPECIFIC;
|
return S48_UNSPECIFIC;
|
||||||
|
@ -449,8 +490,16 @@ s48_value scsh_fchown(s48_value sch_fd, s48_value sch_uid, s48_value sch_gid)
|
||||||
|
|
||||||
s48_value scsh_access(s48_value sch_path, s48_value sch_mode)
|
s48_value scsh_access(s48_value sch_path, s48_value sch_mode)
|
||||||
{
|
{
|
||||||
int retval = access (s48_extract_string(sch_path),
|
int retval;
|
||||||
|
S48_DECLARE_GC_PROTECT(2);
|
||||||
|
|
||||||
|
S48_GC_PROTECT_2(sch_path, sch_mode);
|
||||||
|
|
||||||
|
retval = access (s48_extract_string(sch_path),
|
||||||
s48_extract_integer(sch_mode));
|
s48_extract_integer(sch_mode));
|
||||||
|
|
||||||
|
S48_GC_UNPROTECT();
|
||||||
|
|
||||||
if (retval == -1)
|
if (retval == -1)
|
||||||
s48_raise_os_error_2(errno, sch_path, sch_mode);
|
s48_raise_os_error_2(errno, sch_path, sch_mode);
|
||||||
return S48_UNSPECIFIC;
|
return S48_UNSPECIFIC;
|
||||||
|
@ -565,8 +614,16 @@ s48_value scsh_symlink(s48_value sch_name1, s48_value sch_name2)
|
||||||
|
|
||||||
s48_value scsh_truncate(s48_value sch_path, s48_value sch_length)
|
s48_value scsh_truncate(s48_value sch_path, s48_value sch_length)
|
||||||
{
|
{
|
||||||
int retval = truncate (s48_extract_string (sch_path),
|
int retval;
|
||||||
|
S48_DECLARE_GC_PROTECT(2);
|
||||||
|
|
||||||
|
S48_GC_PROTECT_2(sch_path, sch_length);
|
||||||
|
|
||||||
|
retval = truncate (s48_extract_string (sch_path),
|
||||||
s48_extract_integer (sch_length));
|
s48_extract_integer (sch_length));
|
||||||
|
|
||||||
|
S48_GC_UNPROTECT();
|
||||||
|
|
||||||
if (retval == -1)
|
if (retval == -1)
|
||||||
s48_raise_os_error_2(errno, sch_path, sch_length);
|
s48_raise_os_error_2(errno, sch_path, sch_length);
|
||||||
return S48_UNSPECIFIC;
|
return S48_UNSPECIFIC;
|
||||||
|
@ -574,8 +631,17 @@ s48_value scsh_truncate(s48_value sch_path, s48_value sch_length)
|
||||||
|
|
||||||
s48_value scsh_ftruncate(s48_value sch_fdes, s48_value sch_length)
|
s48_value scsh_ftruncate(s48_value sch_fdes, s48_value sch_length)
|
||||||
{
|
{
|
||||||
int retval = ftruncate (s48_extract_fixnum (sch_fdes),
|
int retval;
|
||||||
|
|
||||||
|
S48_DECLARE_GC_PROTECT(2);
|
||||||
|
|
||||||
|
S48_GC_PROTECT_2(sch_fdes, sch_length);
|
||||||
|
|
||||||
|
retval = ftruncate (s48_extract_fixnum (sch_fdes),
|
||||||
s48_extract_integer (sch_length));
|
s48_extract_integer (sch_length));
|
||||||
|
|
||||||
|
S48_GC_UNPROTECT();
|
||||||
|
|
||||||
if (retval == -1)
|
if (retval == -1)
|
||||||
s48_raise_os_error_2(errno, sch_fdes, sch_length);
|
s48_raise_os_error_2(errno, sch_fdes, sch_length);
|
||||||
return S48_UNSPECIFIC;
|
return S48_UNSPECIFIC;
|
||||||
|
@ -633,9 +699,17 @@ s48_value scsh_dup2(s48_value sch_oldd, s48_value sch_newd)
|
||||||
s48_value scsh_lseek(s48_value sch_fdes, s48_value sch_offset,
|
s48_value scsh_lseek(s48_value sch_fdes, s48_value sch_offset,
|
||||||
s48_value sch_whence)
|
s48_value sch_whence)
|
||||||
{
|
{
|
||||||
int retval = lseek (s48_extract_fixnum (sch_fdes),
|
int retval;
|
||||||
|
S48_DECLARE_GC_PROTECT(3);
|
||||||
|
|
||||||
|
S48_GC_PROTECT_3(sch_fdes, sch_offset, sch_whence);
|
||||||
|
|
||||||
|
retval = lseek (s48_extract_fixnum (sch_fdes),
|
||||||
s48_extract_integer (sch_offset),
|
s48_extract_integer (sch_offset),
|
||||||
s48_extract_fixnum (sch_whence));
|
s48_extract_fixnum (sch_whence));
|
||||||
|
|
||||||
|
S48_GC_UNPROTECT();
|
||||||
|
|
||||||
if (retval == -1)
|
if (retval == -1)
|
||||||
s48_raise_os_error_3 (errno, sch_fdes, sch_offset, sch_whence);
|
s48_raise_os_error_3 (errno, sch_fdes, sch_offset, sch_whence);
|
||||||
return s48_enter_integer (retval);
|
return s48_enter_integer (retval);
|
||||||
|
@ -690,7 +764,15 @@ s48_value scsh_getegid()
|
||||||
|
|
||||||
s48_value scsh_setgid(s48_value gid)
|
s48_value scsh_setgid(s48_value gid)
|
||||||
{
|
{
|
||||||
int retval = setgid (s48_extract_integer (gid));
|
int retval;
|
||||||
|
S48_DECLARE_GC_PROTECT(1);
|
||||||
|
|
||||||
|
S48_GC_PROTECT_1(gid);
|
||||||
|
|
||||||
|
retval = setgid (s48_extract_integer (gid));
|
||||||
|
|
||||||
|
S48_GC_UNPROTECT();
|
||||||
|
|
||||||
if (retval == -1)
|
if (retval == -1)
|
||||||
s48_raise_os_error_1(errno, gid);
|
s48_raise_os_error_1(errno, gid);
|
||||||
return S48_UNSPECIFIC;
|
return S48_UNSPECIFIC;
|
||||||
|
@ -698,11 +780,19 @@ s48_value scsh_setgid(s48_value gid)
|
||||||
|
|
||||||
s48_value scsh_setegid(s48_value gid)
|
s48_value scsh_setegid(s48_value gid)
|
||||||
{
|
{
|
||||||
|
int retval;
|
||||||
|
S48_DECLARE_GC_PROTECT(1);
|
||||||
|
|
||||||
|
S48_GC_PROTECT_1(gid);
|
||||||
|
|
||||||
#ifdef HAVE_SETEGID
|
#ifdef HAVE_SETEGID
|
||||||
int retval = setegid (s48_extract_integer (gid));
|
retval = setegid (s48_extract_integer (gid));
|
||||||
#else
|
#else
|
||||||
int retval = setregid (-1, s48_extract_integer (gid));
|
retval = setregid (-1, s48_extract_integer (gid));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
S48_GC_UNPROTECT();
|
||||||
|
|
||||||
if (retval == -1)
|
if (retval == -1)
|
||||||
s48_raise_os_error_1(errno, gid);
|
s48_raise_os_error_1(errno, gid);
|
||||||
return S48_UNSPECIFIC;
|
return S48_UNSPECIFIC;
|
||||||
|
@ -757,7 +847,15 @@ s48_value scsh_geteuid()
|
||||||
|
|
||||||
s48_value scsh_setuid(s48_value uid)
|
s48_value scsh_setuid(s48_value uid)
|
||||||
{
|
{
|
||||||
int retval = setuid (s48_extract_integer (uid));
|
int retval;
|
||||||
|
S48_DECLARE_GC_PROTECT(1);
|
||||||
|
|
||||||
|
S48_GC_PROTECT_1(uid);
|
||||||
|
|
||||||
|
retval = setuid (s48_extract_integer (uid));
|
||||||
|
|
||||||
|
S48_GC_UNPROTECT();
|
||||||
|
|
||||||
if (retval == -1)
|
if (retval == -1)
|
||||||
s48_raise_os_error_1(errno, uid);
|
s48_raise_os_error_1(errno, uid);
|
||||||
return S48_UNSPECIFIC;
|
return S48_UNSPECIFIC;
|
||||||
|
@ -765,11 +863,19 @@ s48_value scsh_setuid(s48_value uid)
|
||||||
|
|
||||||
s48_value scsh_seteuid(s48_value uid)
|
s48_value scsh_seteuid(s48_value uid)
|
||||||
{
|
{
|
||||||
|
int retval;
|
||||||
|
S48_DECLARE_GC_PROTECT(1);
|
||||||
|
|
||||||
|
S48_GC_PROTECT_1(uid);
|
||||||
|
|
||||||
#ifdef HAVE_SETEUID
|
#ifdef HAVE_SETEUID
|
||||||
int retval = seteuid (s48_extract_integer (uid));
|
retval = seteuid (s48_extract_integer (uid));
|
||||||
#else
|
#else
|
||||||
int retval = setreuid (-1, s48_extract_integer (uid));
|
retval = setreuid (-1, s48_extract_integer (uid));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
S48_GC_UNPROTECT();
|
||||||
|
|
||||||
if (retval == -1)
|
if (retval == -1)
|
||||||
s48_raise_os_error_1(errno, uid);
|
s48_raise_os_error_1(errno, uid);
|
||||||
return S48_UNSPECIFIC;
|
return S48_UNSPECIFIC;
|
||||||
|
@ -792,8 +898,16 @@ s48_value scsh_getpgrp()
|
||||||
|
|
||||||
s48_value scsh_setpgid(s48_value sch_pid, s48_value sch_pgrp)
|
s48_value scsh_setpgid(s48_value sch_pid, s48_value sch_pgrp)
|
||||||
{
|
{
|
||||||
int retval = setpgid(s48_extract_integer(sch_pid),
|
int retval;
|
||||||
|
S48_DECLARE_GC_PROTECT(2);
|
||||||
|
|
||||||
|
S48_GC_PROTECT_2(sch_pid, sch_pgrp);
|
||||||
|
|
||||||
|
retval = setpgid(s48_extract_integer(sch_pid),
|
||||||
s48_extract_integer(sch_pgrp));
|
s48_extract_integer(sch_pgrp));
|
||||||
|
|
||||||
|
S48_GC_UNPROTECT();
|
||||||
|
|
||||||
if (retval == -1)
|
if (retval == -1)
|
||||||
s48_raise_os_error_2(errno, sch_pid, sch_pgrp);
|
s48_raise_os_error_2(errno, sch_pid, sch_pgrp);
|
||||||
return S48_UNSPECIFIC;
|
return S48_UNSPECIFIC;
|
||||||
|
@ -962,8 +1076,16 @@ s48_value errno_msg(s48_value sch_i)
|
||||||
|
|
||||||
s48_value fcntl_read(s48_value fd, s48_value command)
|
s48_value fcntl_read(s48_value fd, s48_value command)
|
||||||
{
|
{
|
||||||
int ret = fcntl(s48_extract_fixnum (fd),
|
int ret;
|
||||||
|
S48_DECLARE_GC_PROTECT(2);
|
||||||
|
|
||||||
|
S48_GC_PROTECT_2(fd, command);
|
||||||
|
|
||||||
|
ret = fcntl(s48_extract_fixnum (fd),
|
||||||
s48_extract_integer (command));
|
s48_extract_integer (command));
|
||||||
|
|
||||||
|
S48_GC_UNPROTECT();
|
||||||
|
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
s48_raise_os_error_2(errno, fd, command);
|
s48_raise_os_error_2(errno, fd, command);
|
||||||
else return s48_enter_fixnum (ret);
|
else return s48_enter_fixnum (ret);
|
||||||
|
@ -972,9 +1094,18 @@ s48_value fcntl_read(s48_value fd, s48_value command)
|
||||||
|
|
||||||
s48_value fcntl_write(s48_value fd, s48_value command, s48_value value)
|
s48_value fcntl_write(s48_value fd, s48_value command, s48_value value)
|
||||||
{
|
{
|
||||||
int ret = fcntl(s48_extract_fixnum (fd),
|
int ret;
|
||||||
|
|
||||||
|
S48_DECLARE_GC_PROTECT(3);
|
||||||
|
|
||||||
|
S48_GC_PROTECT_3(fd, command, value);
|
||||||
|
|
||||||
|
ret = fcntl(s48_extract_fixnum (fd),
|
||||||
s48_extract_integer (command),
|
s48_extract_integer (command),
|
||||||
s48_extract_integer (value));
|
s48_extract_integer (value));
|
||||||
|
|
||||||
|
S48_GC_UNPROTECT();
|
||||||
|
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
s48_raise_os_error_3(errno, fd, command, value);
|
s48_raise_os_error_3(errno, fd, command, value);
|
||||||
else return s48_enter_fixnum (ret);
|
else return s48_enter_fixnum (ret);
|
||||||
|
|
Loading…
Reference in New Issue