]> granicus.if.org Git - php/commitdiff
MFH: Added missing input validation to dio_write().
authorIlia Alshanetsky <iliaa@php.net>
Mon, 30 Aug 2004 22:21:18 +0000 (22:21 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Mon, 30 Aug 2004 22:21:18 +0000 (22:21 +0000)
ext/dio/dio.c

index 90e07b6a779fee59db7d1ce9ba1aa0c3a9029955..6825714105712a8f49a29e7c36f47238dde261c5 100644 (file)
@@ -232,6 +232,12 @@ PHP_FUNCTION(dio_write)
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|l", &r_fd, &data, &data_len, &trunc_len) == FAILURE) {
                return;
        }
+
+       if (trunc_len <= 0 || trunc_len > data_len) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "length must be greater then zero and less then the length of specified string.");
+               RETURN_FALSE;
+       }
+
        ZEND_FETCH_RESOURCE(f, php_fd_t *, &r_fd, -1, le_fd_name, le_fd);
 
        res = write(f->fd, data, trunc_len ? trunc_len : data_len);