smalot / cups-ipp

CUPS Implementation of IPP - PHP Client API
GNU General Public License v2.0
106 stars 56 forks source link

ResponseParser::readValue -> offset is larger than content length #23

Closed AJNaveso closed 3 years ago

AJNaveso commented 3 years ago

The offset is generated by a loop in readAttributeName and it stops adding to the offset when ($this->offset >= strlen($this->content).

When the readAttributeName function is finished, readValue is called. Here we have this piece of code: $value_length = ord($this->content[$this->offset]) * 256 + ord($this->content[$this->offset + 1]);

With this flow an error is always thrown because the last character of the content string is content[N-1]. content[N] never exists, let alone content[$this->offset + 1].

This happens when trying to get the printer list from PrinterManager::getList().

Any suggestions on how to fix this?

AJNaveso commented 3 years ago

I got it working again. The CUPS server is running on an Apache server and it was accessing the Apache server.

I had to add my CUPS port to the localhost in Client.php:


 $host = preg_match(
          '/unix:\/\//',
          $socketClientOptions['remote_socket']
        ) ? 'http://localhost' : $socketClientOptions['remote_socket'];`