Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve compatibility of SNMP class trim handling under PHP 8.x #5420

Closed
anarkia1976 opened this issue Jul 24, 2023 · 10 comments
Closed

Improve compatibility of SNMP class trim handling under PHP 8.x #5420

anarkia1976 opened this issue Jul 24, 2023 · 10 comments
Labels
bug Undesired behaviour confirmed Bug is confirm by dev team resolved A fixed issue
Milestone

Comments

@anarkia1976
Copy link

Hi Guys,

i see some errors after latest patches:


2023-07-24 12:26:11 - CMDPHP PHP ERROR WARNING Backtrace: (/host.php[141]:api_device_ping_device(), /lib/api_device.php[1543]:cacti_snmp_session_get(), /lib/snmp.php[497]:SNMP->get(), CactiErrorHandler())
2023-07-24 12:26:11 - ERROR PHP WARNING: SNMP::get(): Fatal error: Failure in sendto (Invalid argument) in file: /var/www/html/cacti/lib/snmp.php on line: 497
2023-07-24 12:26:11 - CMDPHP PHP ERROR WARNING Backtrace: (/host.php[126]:host_reload_query(), /host.php[624]:run_data_query(), /lib/data_query.php[106]:query_snmp_host(), /lib/data_query.php[912]:cacti_snmp_session_get(), /lib/snmp.php[497]:SNMP->get(), CactiErrorHandler())
2023-07-24 12:26:11 - ERROR PHP WARNING: SNMP::get(): Fatal error: Failure in sendto (Invalid argument) in file: /var/www/html/cacti/lib/snmp.php on line: 497
2023-07-24 12:26:11 - CMDPHP PHP ERROR WARNING Backtrace: (/host.php[126]:host_reload_query(), /host.php[624]:run_data_query(), /lib/data_query.php[106]:query_snmp_host(), /lib/data_query.php[863]:cacti_snmp_session_walk(), /lib/snmp.php[460]:SNMP->walk(), CactiErrorHandler())
2023-07-24 12:26:11 - ERROR PHP WARNING: SNMP::walk(): Fatal error: Failure in sendto (Invalid argument) in file: /var/www/html/cacti/lib/snmp.php on line: 460
2023-07-24 12:26:11 - CMDPHP PHP ERROR WARNING Backtrace: (/host.php[126]:host_reload_query(), /host.php[624]:run_data_query(), /lib/data_query.php[106]:query_snmp_host(), /lib/data_query.php[863]:cacti_snmp_session_walk(), /lib/snmp.php[460]:SNMP->walk(), CactiErrorHandler())
2023-07-24 12:26:11 - ERROR PHP WARNING: SNMP::walk(): Fatal error: Failure in sendto (Invalid argument) in file: /var/www/html/cacti/lib/snmp.php on line: 460
2023-07-24 12:26:11 - CMDPHP PHP ERROR WARNING Backtrace: (/host.php[126]:host_reload_query(), /host.php[624]:run_data_query(), /lib/data_query.php[106]:query_snmp_host(), /lib/data_query.php[863]:cacti_snmp_session_walk(), /lib/snmp.php[460]:SNMP->walk(), CactiErrorHandler())
2023-07-24 12:26:11 - ERROR PHP WARNING: SNMP::walk(): Fatal error: Failure in sendto (Invalid argument) in file: /var/www/html/cacti/lib/snmp.php on line: 460
2023-07-24 12:26:11 - CMDPHP PHP ERROR WARNING Backtrace: (/host.php[126]:host_reload_query(), /host.php[624]:run_data_query(), /lib/data_query.php[106]:query_snmp_host(), /lib/data_query.php[863]:cacti_snmp_session_walk(), /lib/snmp.php[460]:SNMP->walk(), CactiErrorHandler())
2023-07-24 12:26:11 - ERROR PHP WARNING: SNMP::walk(): Fatal error: Failure in sendto (Invalid argument) in file: /var/www/html/cacti/lib/snmp.php on line: 460
2023-07-24 12:26:00 - CMDPHP PHP ERROR WARNING Backtrace: (/host.php[141]:api_device_ping_device(), /lib/api_device.php[1543]:cacti_snmp_session_get(), /lib/snmp.php[497]:SNMP->get(), CactiErrorHandler())
2023-07-24 12:26:00 - ERROR PHP WARNING: SNMP::get(): Fatal error: Failure in sendto (Invalid argument) in file: /var/www/html/cacti/lib/snmp.php on line: 497

thanks a lot. stefano.

@anarkia1976 anarkia1976 added bug Undesired behaviour unverified Some days we don't have a clue labels Jul 24, 2023
@TheWitness
Copy link
Member

Well, that's odd. It's potentially trimming an array. I thought it was simply a string. This may have been introduced by @netniV converting the library to use multiple OID's in a single request. Not sure why it's showing up now. I'll do a little research this morning.

@TheWitness
Copy link
Member

Yup. Let me fix it.

image

@TheWitness TheWitness changed the title [CACTI 1.2.25 - latest source] PHP and SNMP errors PHP8.1.x, PHP-SNMP and snmp->get() errors due to improper use of trim() function Jul 24, 2023
TheWitness added a commit that referenced this issue Jul 24, 2023
PHP8.1.x, PHP-SNMP and snmp->get() errors due to improper use of trim() function
@TheWitness TheWitness added resolved A fixed issue confirmed Bug is confirm by dev team and removed unverified Some days we don't have a clue labels Jul 24, 2023
@TheWitness
Copy link
Member

@anarkia1976, Should be resolved now. Report back after you have tested this as clean and close if all good.

TheWitness added a commit that referenced this issue Jul 24, 2023
PHP8.1.x, PHP-SNMP and snmp->get() errors due to improper use of trim() function
@netniV
Copy link
Member

netniV commented Jul 24, 2023

Do we need to check the other functions for trim too?

@TheWitness
Copy link
Member

I'm doing that right now.

@TheWitness
Copy link
Member

$session->getnext() was affected too.

@TheWitness
Copy link
Member

What's odd is that the $session->walk() supports an array too. I don't know anywhere where were are using it that way. We would need to write a test case for that as it would result in a multi-dimensional return array.

TheWitness added a commit that referenced this issue Jul 24, 2023
PHP8.1.x, PHP-SNMP and snmp->get() errors due to improper use of trim() function
@TheWitness
Copy link
Member

@netniV, check my last commit on the $session->walk() validation.

TheWitness added a commit that referenced this issue Jul 24, 2023
PHP8.1.x, PHP-SNMP and snmp->get() errors due to improper use of trim() function
@netniV
Copy link
Member

netniV commented Jul 24, 2023

Should have made the loops into a a function for cleaner code, You could even have parameters such as a format flag and those of format_snmp_string so that they be passed on to it when format was true instead of trim?

@TheWitness
Copy link
Member

Going to mark resolved for now. We can always revisit this later.

@netniV netniV changed the title PHP8.1.x, PHP-SNMP and snmp->get() errors due to improper use of trim() function Improve combability of SNMP class trim handling for PHP 8.x Sep 3, 2023
@netniV netniV changed the title Improve combability of SNMP class trim handling for PHP 8.x Improve combability of SNMP class trim handling under PHP 8.x Sep 3, 2023
@netniV netniV changed the title Improve combability of SNMP class trim handling under PHP 8.x Improve compatibility of SNMP class trim handling under PHP 8.x Sep 3, 2023
@netniV netniV added this to the v1.2.25 milestone Sep 4, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Dec 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Undesired behaviour confirmed Bug is confirm by dev team resolved A fixed issue
Projects
None yet
Development

No branches or pull requests

3 participants