summaryrefslogtreecommitdiffstats
path: root/byterun/sys.c
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2014-04-15 17:09:13 +0000
committerXavier Leroy <xavier.leroy@inria.fr>2014-04-15 17:09:13 +0000
commit774e30e138dc22a5acd6cfac03ae25194ae8cd6e (patch)
tree2acda83264153258c7f978efeae08d260598c023 /byterun/sys.c
parent2fc7ac7e8b95a143b6b38eab28622389cc19001b (diff)
PR#6075: avoid using unsafe C library functions (strcpy, strcat, sprintf).
An ISO C99-compliant C compiler and standard library is now assumed. (Plus special exceptions for MSVC.) In particular, emulation code for 64-bit integer arithmetic was removed, the C compiler must support a 64-bit integer type. git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14607 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'byterun/sys.c')
-rw-r--r--byterun/sys.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/byterun/sys.c b/byterun/sys.c
index 8b2551a00..ee2a77024 100644
--- a/byterun/sys.c
+++ b/byterun/sys.c
@@ -125,7 +125,7 @@ CAMLprim value caml_sys_open(value path, value vflags, value vperm)
int fd, flags, perm;
char * p;
- p = caml_stat_alloc_string(path);
+ p = caml_strdup(String_val(path));
flags = caml_convert_flag_list(vflags, sys_open_flags);
perm = Int_val(vperm);
/* open on a named FIFO can block (PR#1533) */
@@ -156,7 +156,7 @@ CAMLprim value caml_sys_file_exists(value name)
char * p;
int ret;
- p = caml_stat_alloc_string(name);
+ p = caml_strdup(String_val(name));
caml_enter_blocking_section();
ret = stat(p, &st);
caml_leave_blocking_section();
@@ -172,7 +172,7 @@ CAMLprim value caml_sys_is_directory(value name)
char * p;
int ret;
- p = caml_stat_alloc_string(name);
+ p = caml_strdup(String_val(name));
caml_enter_blocking_section();
ret = stat(p, &st);
caml_leave_blocking_section();
@@ -191,7 +191,7 @@ CAMLprim value caml_sys_remove(value name)
CAMLparam1(name);
char * p;
int ret;
- p = caml_stat_alloc_string(name);
+ p = caml_strdup(String_val(name));
caml_enter_blocking_section();
ret = unlink(p);
caml_leave_blocking_section();
@@ -205,8 +205,8 @@ CAMLprim value caml_sys_rename(value oldname, value newname)
char * p_old;
char * p_new;
int ret;
- p_old = caml_stat_alloc_string(oldname);
- p_new = caml_stat_alloc_string(newname);
+ p_old = caml_strdup(String_val(oldname));
+ p_new = caml_strdup(String_val(newname));
caml_enter_blocking_section();
ret = rename(p_old, p_new);
caml_leave_blocking_section();
@@ -222,7 +222,7 @@ CAMLprim value caml_sys_chdir(value dirname)
CAMLparam1(dirname);
char * p;
int ret;
- p = caml_stat_alloc_string(dirname);
+ p = caml_strdup(String_val(dirname));
caml_enter_blocking_section();
ret = chdir(p);
caml_leave_blocking_section();
@@ -289,7 +289,7 @@ CAMLprim value caml_sys_system_command(value command)
int status, retcode;
char *buf;
- buf = caml_stat_alloc_string(command);
+ buf = caml_strdup(String_val(command));
caml_enter_blocking_section ();
status = system(buf);
caml_leave_blocking_section ();
@@ -430,7 +430,7 @@ CAMLprim value caml_sys_read_directory(value path)
int ret;
caml_ext_table_init(&tbl, 50);
- p = caml_stat_alloc_string(path);
+ p = caml_strdup(String_val(path));
caml_enter_blocking_section();
ret = caml_read_directory(p, &tbl);
caml_leave_blocking_section();