]> granicus.if.org Git - php/commitdiff
We shoud not fseek in a pipe and this caused a problem with popen and
authorAlexander Feldman <sasha@php.net>
Sun, 15 Apr 2001 18:42:50 +0000 (18:42 +0000)
committerAlexander Feldman <sasha@php.net>
Sun, 15 Apr 2001 18:42:50 +0000 (18:42 +0000)
fgets on the platforms where the buffer fix was applied (Solaris, FreeBSD).
Now the fseek is done only when the handle is of type fopen.

ext/standard/file.c

index 79e42f8a74e5f75132a863df893ca58ed1577dd4..d1d3101de9e97e49369693d75962c8693b2704a4 100644 (file)
@@ -921,7 +921,7 @@ PHP_FUNCTION(fgets)
        /* needed because recv doesnt put a null at the end*/
        memset(buf,0,len+1);
 #ifdef HAVE_FLUSHIO
-       if (!issock) {
+       if (type == le_fopen) {
                fseek((FILE*)what, 0, SEEK_CUR);
        }
 #endif
@@ -969,7 +969,7 @@ PHP_FUNCTION(fgetc) {
        }
 
 #ifdef HAVE_FLUSHIO
-       if (!issock) {
+       if (type == le_fopen) {
                fseek((FILE*)what, 0, SEEK_CUR);
        }
 #endif
@@ -1172,7 +1172,9 @@ PHP_FUNCTION(fwrite)
                ret = SOCK_WRITEL((*arg2)->value.str.val,num_bytes,socketd);
        } else {
 #ifdef HAVE_FLUSHIO
-               fseek((FILE*)what, 0, SEEK_CUR);
+               if (type == le_fopen) {
+                       fseek((FILE*)what, 0, SEEK_CUR);
+               }
 #endif
                ret = fwrite((*arg2)->value.str.val,1,num_bytes,(FILE*)what);
        }
@@ -1814,7 +1816,9 @@ PHP_FUNCTION(fread)
        
        if (!issock) {
 #ifdef HAVE_FLUSHIO
-               fseek((FILE*)what, 0, SEEK_CUR);
+               if (type == le_fopen)
+                       fseek((FILE*)what, 0, SEEK_CUR);
+               }
 #endif
                return_value->value.str.len = fread(return_value->value.str.val, 1, len, (FILE*)what);
                return_value->value.str.val[return_value->value.str.len] = 0;