Since seek after the end is not considered an error, I doubt that "while (gzseek ($fh, $eof) == 0) $eof += $d;" will get into infinite loop.(PHP 4, PHP 5, PHP 7, PHP 8)
gzseek — Ubica el apuntador a un archivo gz
   Establece el indicador de posición para el apuntador al archivo
   dado en el desplazamiento de bytes fijado en el flujo del archivo.
   Es equivalente a llamar (en C) a gzseek(zp, offset, SEEK_SET).
  
Si el archivo está abierto para lectura, ésta función es emulada pero puede ser extremadamente lenta. Si el archivo está abierto para escritura, sólo está soportada la búsqueda hacia adelante; entonces gzseek() comprime una secuencia de ceros hasta la nueva posición de inicio.
streamEl apuntador al archivo gz. Debe ser válido y debe apuntar a un archivo abierto exitosamente por gzopen().
offsetEl desplazamiento buscado.
whence
       Los valores de whence son:
       
SEEK_SET - Establece la posición igual al offset de bytes.SEEK_CUR - Establece la posición en la posición actual más el offset.
       Si whence no se especifica, se asume que es
       SEEK_SET.
      
En caso de éxito, retorna 0; en caso contrario, devuelve -1. Notese que buscar pasado el EOF no es considerado un error.
Ejemplo #1 Ejamplo de gzseek()
<?php
$gz = gzopen('somefile.gz', 'r');
gzseek($gz,2);
echo gzgetc($gz);
gzclose($gz);
?>
Since seek after the end is not considered an error, I doubt that "while (gzseek ($fh, $eof) == 0) $eof += $d;" will get into infinite loop.PHP/4.3.9
contrary to the notes, gzseek() returns -1 if I try to seek past the end of the file.  here is a function that will return the last seekable position, and put the file pointer there.
/** sets the file pointer at the end of the file
 *  and returns the number of bytes in the file.
 */
function gzend($fh)
{
   $d   = 1<<14;
   $eof = $d;
   while ( gzseek($fh, $eof) == 0 ) $eof += $d;
   while ( $d > 1 )
   {
      $d >>= 1;
      $eof += $d * (gzseek($fh, $eof)? -1 : 1);
   }
   return $eof;
}