]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Fix lua_alloc_cmd (#4813)
authorMax Khon <fjoe@samodelkin.net>
Tue, 6 Dec 2022 17:55:35 +0000 (17:55 +0000)
committerGitHub <noreply@github.com>
Tue, 6 Dec 2022 17:55:35 +0000 (11:55 -0600)
(0)      redis_ippool - ERROR: (0) error   : ERR Error running script (call to f_555f9a10a670669b1725edfc4b558c4c5eb3f9ad): @user_script:14: user_script:14: attempt to compare number with string

src/modules/rlm_redis_ippool/rlm_redis_ippool.c

index 3a8816532fc539f63f6c63029376932cf96266ad..5a393319bdf72c1d57a96d2e7f9fa4e13d595b31 100644 (file)
@@ -215,9 +215,9 @@ static char lua_alloc_cmd[] =
        "  if expires_in > 0 then" EOL                                                                  /* 11 */
        "    ip = redis.call('HMGET', '{' .. KEYS[1] .. '}:"IPPOOL_ADDRESS_KEY":' .. exists, 'device', 'range', 'counter')" EOL /* 12 */
        "    if ip and (ip[1] == ARGV[3]) then" EOL                                                     /* 13 */
-       "      if expires_in < ARGV[2] then" EOL                                                        /* 14 */
-       "        redis.call('ZADD', pool_key, 'XX', ARGV[1] + ARGV[2], ip[1])" EOL                      /* 15 */
-       "        expires_in = ARGV[2]" EOL                                                              /* 16 */
+       "      if expires_in < tonumber(ARGV[2]) then" EOL                                              /* 14 */
+       "        redis.call('ZADD', pool_key, 'XX', ARGV[1] + ARGV[2], exists)" EOL                     /* 15 */
+       "        expires_in = tonumber(ARGV[2])" EOL                                                    /* 16 */
        "      end" EOL                                                                                 /* 17 */
        "      return {" STRINGIFY(_IPPOOL_RCODE_SUCCESS) ", exists, ip[2], expires_in, ip[3] }" EOL    /* 18 */
        "    end" EOL                                                                                   /* 19 */