PR#6945 and GPR#227: protect Sys and Unix functions against string arguments containing the null character '\000'

Continuation of commit dc043a7:
- Protect Sys.command
master
Xavier Leroy 2015-11-13 14:57:12 +01:00
parent 29a50b4768
commit dc2a98c3a5
1 changed files with 4 additions and 0 deletions

View File

@ -339,6 +339,10 @@ CAMLprim value caml_sys_system_command(value command)
int status, retcode;
char *buf;
if (! caml_string_is_c_safe (command)) {
errno = EINVAL;
caml_sys_error(command);
}
buf = caml_strdup(String_val(command));
caml_enter_blocking_section ();
status = system(buf);