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 — Posiciona um ponteiro de arquivo gz
   Define o indicador de posição de arquivo para o ponteiro de arquivo
   dado no byte de deslocamento na sequência de arquivo. Equivalente a chamar (em C)
   gzseek(zp, offset, SEEK_SET).
  
Se o arquivo estiver aberto para leitura, esta função é emulada mas pode ser extremamente lenta. Se o arquivo estiver aberto para escrita, apenas buscas para frente são suportadas; gzseek() então comprime uma sequência de zeros até a nova posição inicial.
streamO ponteiro de arquivo gz. Ele deve ser válido e deve apontar para um arquivo aberto com sucesso por gzopen().
offsetO deslocamento buscado.
whence
       Valores de whence podem ser:
       
SEEK_SET - Define a posição igual a offset bytes.SEEK_CUR - Define a posição para a localização atual mais offset.
       Se whence não for especificado, assume-se que é
       SEEK_SET.
      
Em caso de sucesso, retorna 0; caso contrário, retorna -1. Note que buscar além do EOF não é considerado um erro.
Exemplo #1 Exemplo de gzseek()
<?php
$gz = gzopen('algumarquivo.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;
}