]> granicus.if.org Git - php/commitdiff
Made fgetss() binary safe too
authorMoriyoshi Koizumi <moriyoshi@php.net>
Mon, 24 Feb 2003 22:39:47 +0000 (22:39 +0000)
committerMoriyoshi Koizumi <moriyoshi@php.net>
Mon, 24 Feb 2003 22:39:47 +0000 (22:39 +0000)
ext/standard/file.c

index b4f118b76cd3f22aea16e2bbf9cf8cb06784aa63..24739957b99b4d2331f0880c83311ec294a2678e 100644 (file)
@@ -1675,6 +1675,7 @@ PHPAPI PHP_FUNCTION(fgetss)
 {
        zval **fd, **bytes, **allow=NULL;
        int len;
+       size_t actual_len, retval_len;
        char *buf;
        php_stream *stream;
        char *allowed_tags=NULL;
@@ -1713,15 +1714,15 @@ PHPAPI PHP_FUNCTION(fgetss)
        /*needed because recv doesnt set null char at end*/
        memset(buf, 0, len + 1);
 
-       if (php_stream_gets(stream, buf, len) == NULL)  {
+       if (php_stream_get_line(stream, buf, len, &actual_len) == NULL) {
                efree(buf);
                RETURN_FALSE;
        }
 
        /* strlen() can be used here since we are doing it on the return of an fgets() anyway */
-       php_strip_tags(buf, strlen(buf), &stream->fgetss_state, allowed_tags, allowed_tags_len);
+       retval_len = php_strip_tags(buf, actual_len, &stream->fgetss_state, allowed_tags, allowed_tags_len);
 
-       RETURN_STRING(buf, 0);
+       RETURN_STRINGL(buf, retval_len, 0);
 }
 /* }}} */