nextcloud / limit_login_to_ip

Nextcloud app that lets you Limit login to IP ranges
https://apps.nextcloud.com/apps/limit_login_to_ip
GNU Affero General Public License v3.0
24 stars 17 forks source link

Error: Undefined offset: 1 at /var/www/nextcloud/apps/limit_login_to_ip/lib/LoginHookListener.php#65 #59

Closed Irkhar closed 1 year ago

Irkhar commented 3 years ago

After updating to version 3.1.0, I have such errors in the log. I am asking for help in solving the problem.

Nextcloud 19.0.6

`[PHP] Error: Error: Undefined offset: 1 at /var/www/nextcloud/apps/limit_login_to_ip/lib/LoginHookListener.php#65 at <>

  1. /var/www/nextcloud/apps/limit_login_to_ip/lib/LoginHookListener.php line 65 OC\Log\ErrorHandler::onError(8, "Undefined offset: 1", "/var/www/nextcl ... p", 65, {ip: "172.XX.XX. ... "})
  2. /var/www/nextcloud/apps/limit_login_to_ip/lib/LoginHookListener.php line 120 OCA\LimitLoginToIp\LoginHookListener->matchCidr("172.XX.XX.XX", "")
  3. /var/www/nextcloud/apps/limit_login_to_ip/appinfo/app.php line 40 OCA\LimitLoginToIp\LoginHookListener->isLoginAllowed()
  4. /var/www/nextcloud/lib/private/legacy/OC_App.php line 266 require_once("/var/www/nextcl ... p")
  5. /var/www/nextcloud/lib/private/legacy/OC_App.php line 155 OC_App::requireAppFile("limit_login_to_ip")
  6. /var/www/nextcloud/lib/private/legacy/OC_App.php line 128 OC_App::loadApp("limit_login_to_ip")
  7. /var/www/nextcloud/lib/base.php line 995 OC_App::loadApps()
  8. /var/www/nextcloud/index.php line 37 OC::handleRequest()`
JoNaNas commented 3 years ago

Hey there,

I have the same problem with the app (Version 3.1.0). As soon as I enable the app, my log file gets spammed with these log messages (16 messages/second).

Nextcloud 19.0.8

Error: Undefined offset: 1 at /var/www/nextcloud/apps/limit_login_to_ip/lib/LoginHookListener.php#65

/var/www/nextcloud/apps/limit_login_to_ip/lib/LoginHookListener.php - line 65: OC\Log\ErrorHandler::onError(8, "Undefined offset: 1", "/var/www/ne ... p", 65, { ip: "172.XXX. ... "})

/var/www/nextcloud/apps/limit_login_to_ip/lib/LoginHookListener.php - line 120: OCA\LimitLoginToIp\LoginHookListener->matchCidr("172.XXX.XXX.XXX", "")

/var/www/nextcloud/apps/limit_login_to_ip/appinfo/app.php - line 40: OCA\LimitLoginToIp\LoginHookListener->isLoginAllowed()

/var/www/nextcloud/lib/private/legacy/OC_App.php - line 266: require_once("/var/www/ne ... p")

/var/www/nextcloud/lib/private/legacy/OC_App.php - line 155: OC_App::requireAppFile("limit_login_to_ip")

/var/www/nextcloud/lib/private/legacy/OC_App.php - line 128: OC_App::loadApp("limit_login_to_ip")

/var/www/nextcloud/lib/base.php - line 995: OC_App::loadApps()

/var/www/nextcloud/index.php - line 37: OC::handleRequest()

2021-02-18 08_11_31-Window

schloggi commented 3 years ago

Hi, i have the same problem:

PHP Error: Undefined offset: 1 at /is/htdocs/xxx/www/nc/apps/limit_login_to_ip/lib/LoginHookListener.php#65

NC: 21.0.0 App: 3.1.0

radoeka commented 3 years ago

I'm facing the same issue. Any update for this?

It seems to fail here:

 56         /**
 57          * @param $ip
 58          * @param $range
 59          * @return bool
 60          * @copyright https://stackoverflow.com/questions/594112/matching-an-ip-to-a-cidr-mask-in-php-5/594134#594134
 61          * @copyright (IPv4) https://stackoverflow.com/questions/594112/matching-an-ip-to-a-cidr-mask-in-php-5/594134#594134
 62          * @copyright (IPv6) MW. https://stackoverflow.com/questions/7951061/matching-ipv6-address-to-a-cidr-subnet via 
 63          */
 64         private function matchCidr($ip, $range) {
 65                 list($subnet, $bits) = explode('/', $range);

Which is the code from stackoverflow (at least the 1st one above).

How can this be debugged nicely?

canapaio commented 3 years ago

Hi, i have the same problem:

PHP Error: Undefined offset: 1 at [nc dir]/apps/limit_login_to_ip/lib/LoginHookListener.php#65

NC: 21.0.2

canapaio commented 3 years ago

Solution: I have removed the ip restriction in the security section

jbits-se commented 2 years ago

This error seems to be caused by having an invalid entry under Security -> Restrict login to IP ranges Make sure you have no empty lines or non CIDR entries.

Irkhar commented 2 years ago

I deleted the entry with an empty IP address and it no longer reports an error in the logs. Thank you

Altahrim commented 1 year ago

This issue should be fixed in new version (v4.0.0-beta1). Feel free to reopen if needed :)