Commits

Ruslan Osmanov  committed edcbcc7

Add: file descriptor validation

  • Participants
  • Parent commits da26604

Comments (0)

Files changed (1)

 
 #include "src/common.h"
 #include "src/util.h"
+#include <fcntl.h>
 
 /* {{{ php_event_zval_to_fd
  * Get numeric file descriptor from PHP stream or Socket resource */
 		return -1;
 	}
 
+	/* Validate file descriptor */
+	if (file_desc >= 0 && fcntl(file_desc, F_GETFD) == -1) {
+		php_error_docref(NULL TSRMLS_CC, E_WARNING, "fcntl: invalid file descriptor passed");
+	}
+
 	return file_desc;
 }
 /* }}} */