]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Don't attempt to run zero length queries
authorNick Porter <nick@portercomputing.co.uk>
Mon, 24 Jun 2024 17:35:32 +0000 (18:35 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Mon, 24 Jun 2024 17:35:32 +0000 (18:35 +0100)
Since these come from conf file entries it's all to easy for something
such as

alloc_requested = ''

to be set rather than commenting out the entry.

src/modules/rlm_sqlippool/rlm_sqlippool.c

index b3173ff859fc8706951c094fde817229ae8f7b71..23a7c6b42bb39a4d9aacd488c95f81b8ed7740a2 100644 (file)
@@ -308,7 +308,7 @@ static unlang_action_t mod_alloc_resume(rlm_rcode_t *p_result, UNUSED int *prior
                goto expand_requested;
 
        case IPPOOL_ALLOC_EXISTING:
-               if (query) SUBMIT_QUERY(query->vb_strvalue, IPPOOL_ALLOC_EXISTING_RUN, SQL_QUERY_SELECT, select);
+               if (query && query->vb_length) SUBMIT_QUERY(query->vb_strvalue, IPPOOL_ALLOC_EXISTING_RUN, SQL_QUERY_SELECT, select);
                goto expand_requested;
 
        case IPPOOL_ALLOC_EXISTING_RUN:
@@ -332,7 +332,7 @@ static unlang_action_t mod_alloc_resume(rlm_rcode_t *p_result, UNUSED int *prior
                goto expand_find;
 
        case IPPOOL_ALLOC_REQUESTED:
-               if (query) SUBMIT_QUERY(query->vb_strvalue, IPPOOL_ALLOC_REQUESTED_RUN, SQL_QUERY_SELECT, select);
+               if (query && query->vb_length) SUBMIT_QUERY(query->vb_strvalue, IPPOOL_ALLOC_REQUESTED_RUN, SQL_QUERY_SELECT, select);
 
                goto expand_find;
 
@@ -435,7 +435,7 @@ static unlang_action_t mod_alloc_resume(rlm_rcode_t *p_result, UNUSED int *prior
                 *      Ok, so the allocate-find query found nothing ...
                 *      Let's check if the pool exists at all
                 */
-               if (query) SUBMIT_QUERY(query->vb_strvalue, IPPOOL_ALLOC_POOL_CHECK_RUN, SQL_QUERY_SELECT, select);
+               if (query && query->vb_length) SUBMIT_QUERY(query->vb_strvalue, IPPOOL_ALLOC_POOL_CHECK_RUN, SQL_QUERY_SELECT, select);
                goto no_address;
 
        case IPPOOL_ALLOC_POOL_CHECK_RUN:
@@ -467,7 +467,7 @@ static unlang_action_t mod_alloc_resume(rlm_rcode_t *p_result, UNUSED int *prior
                RETURN_MODULE_NOOP;
 
        case IPPOOL_ALLOC_UPDATE:
-               if (query) SUBMIT_QUERY(query->vb_strvalue, IPPOOL_ALLOC_UPDATE_RUN, SQL_QUERY_OTHER, query);
+               if (query && query->vb_length) SUBMIT_QUERY(query->vb_strvalue, IPPOOL_ALLOC_UPDATE_RUN, SQL_QUERY_OTHER, query);
 
                goto finish;