]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Don't leak reply objects the any time the script needs to be loaded
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 7 Mar 2019 05:22:32 +0000 (13:22 +0800)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 7 Mar 2019 07:37:47 +0000 (15:37 +0800)
This is a pretty minor leak as the scripts are usually only loaded on startup, but if someone kept trashing the script cache, this could become an issue.

src/modules/rlm_redis_ippool/rlm_redis_ippool.c

index 09ae431604e4eba091cd68ea70d5bccfb5ab4c7a..57c521460c02850e5dbc1ce646544bd80c3bf95e 100644 (file)
@@ -460,6 +460,10 @@ static fr_redis_rcode_t ippool_script(redisReply **out, REQUEST *request, fr_red
 
        *out = NULL;
 
+#ifndef NDEBUG
+       memset(replies, 0, sizeof(replies));
+#endif
+
        va_start(ap, cmd);
 
        for (s_ret = fr_redis_cluster_state_init(&state, &conn, cluster, request, key, key_len, false);
@@ -481,6 +485,11 @@ static fr_redis_rcode_t ippool_script(redisReply **out, REQUEST *request, fr_red
                                                     conn);
                if (status != REDIS_RCODE_NO_SCRIPT) continue;
 
+               /*
+                *      Clear out the existing reply
+                */
+               fr_redis_pipeline_free(replies, reply_cnt);
+
                /*
                 *      Last command failed with NOSCRIPT, this means
                 *      we have to send the Lua script up to the node
@@ -665,7 +674,7 @@ static ippool_rcode_t redis_ippool_allocate(rlm_redis_ippool_t const *inst, REQU
                                tmp.type = FR_TYPE_UINT32;
 
                                if (fr_value_box_cast(NULL, &ip_map.rhs->tmpl_value, FR_TYPE_IPV4_ADDR,
-                                                   NULL, &tmp)) {
+                                                     NULL, &tmp)) {
                                        RPEDEBUG("Failed converting integer to IPv4 address");
                                        ret = IPPOOL_RCODE_FAIL;
                                        goto finish;