Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP disable error from specific file?

Tags:

php

phpseclib

I am getting hundreds of from ANSI.php. Here is an example:

/usr/share/pear/File/ANSI.php on line 553 Notice: Undefined offset: 75 in 
/usr/share/pear/File/ANSI.php on line 555 Notice: Undefined offset: 76 in 
/usr/share/pear/File/ANSI.php on line 553 Notice: Undefined offset: 76 in 
/usr/share/pear/File/ANSI.php on line 555 Notice: Undefined offset: 77 in
/usr/share/pear/File/ANSI.php on line 555 Notice: Trying to get property of non-object in
/usr/share/pear/File/ANSI.php on line 496 Notice: Trying to get property of non-object in  

This is generating from:

$ansi->appendString($ssh->read());

Everything is working. I suspect the old machines I am working with are giving ANSI.php a hard time.

Is there a way i can disable just the error messages from ANSI.PHP and keep the others? Unless someone has a way of fixing the error.

like image 723
MoonEater916 Avatar asked Aug 04 '26 03:08

MoonEater916


1 Answers

Simplest Solution (Sub-Optimal)

I guess the simplest way to suppress the errors would be to use the error suppression operator @. eg.

@$ansi->appendString($str);

Optimal Solution (Possibly)

There have been two commits to phpseclib since the latest release (1.0.7 and 2.0.6, as of this post) that fixed issues with File/ANSI.php:

https://github.com/phpseclib/phpseclib/commit/5c792f6bc1fa8a5d26b43fb8200191c073637e15 https://github.com/phpseclib/phpseclib/commit/84d1628cb7734134b1ba80545b38985025942b79

More info:

https://github.com/phpseclib/phpseclib/issues/1161 https://github.com/phpseclib/phpseclib/issues/1150

Kinda makes me wonder if one of those might fix the issue for you.

Fallback to Optimal Solution

If the previously mentioned "optimal solution" doesn't fix the issue for you then it would be nice to fix the problem at the source. What'd help me do that would be a copy of the data you got before you passed it to $ansi->appendString(). To make it so the characters don't get garbled because they're extended ASCII maybe hex encode it. eg. echo bin2hex($ssh->read()); or something.

like image 97
neubert Avatar answered Aug 06 '26 20:08

neubert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!