Browse files

Guard string for null bytes

  • Loading branch information...
1 parent bff09f5 commit b4ded0cc1656cd2f4025d39dd9345bc32fd0db42 @dbussink dbussink committed Mar 17, 2012
Showing with 8 additions and 2 deletions.
  1. +8 −2 vm/builtin/system.cpp
View
10 vm/builtin/system.cpp
@@ -268,12 +268,18 @@ namespace rubinius {
// TODO: Windows
return Primitives::failure();
#else
+
+ const char* c_str = str->c_str(state);
+
+ if(str->byte_size() > (native_int) strlen(c_str)) {
+ Exception::argument_error(state, "string contains null byte");
+ return cNil;
+ }
+
int fds[2];
if(pipe(fds) != 0) return Primitives::failure();
- const char* c_str = str->c_str(state);
-
pid_t pid = fork();
// error

0 comments on commit b4ded0c

Please sign in to comment.