From: Arran Cudbard-Bell Date: Sun, 19 Sep 2021 15:27:28 +0000 (-0500) Subject: FR_TYPE_VOID is better than FR_TYPE_NULL for indicating we want to use the type from... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2327eee6be2abc30204623471adbd67ff435de0d;p=thirdparty%2Ffreeradius-server.git FR_TYPE_VOID is better than FR_TYPE_NULL for indicating we want to use the type from Redis --- diff --git a/src/lib/redis/redis.c b/src/lib/redis/redis.c index 2393adc30a..1292946902 100644 --- a/src/lib/redis/redis.c +++ b/src/lib/redis/redis.c @@ -187,7 +187,7 @@ void fr_redis_reply_print(fr_log_lvl_t lvl, redisReply *reply, request_t *reques * @param[in,out] ctx to allocate any buffers in. * @param[out] out Where to write the cast type. * @param[in] reply to process. - * @param[in] dst_type to convert to. May be FR_TYPE_NULL + * @param[in] dst_type to convert to. May be FR_TYPE_VOID * to infer type. * @param[in] dst_enumv Used to convert string types to * integers for attribute with enumerated @@ -249,6 +249,7 @@ int fr_redis_reply_to_value_box(TALLOC_CTX *ctx, fr_value_box_t *out, redisReply #if HIREDIS_MAJOR >= 1 case REDIS_REPLY_DOUBLE: + /* reply->str is \0 terminated in this case */ fr_value_box_shallow(&in, strtod(reply->str, NULL), true); break; @@ -268,8 +269,6 @@ int fr_redis_reply_to_value_box(TALLOC_CTX *ctx, fr_value_box_t *out, redisReply #if HIREDIS_MAJOR >= 1 case REDIS_REPLY_BIGNUM: /* FIXME - Could try and conver to integer ? */ #endif - - case REDIS_REPLY_STRING: case REDIS_REPLY_STATUS: if (shallow) { @@ -329,12 +328,12 @@ int fr_redis_reply_to_value_box(TALLOC_CTX *ctx, fr_value_box_t *out, redisReply fr_dlist_insert_tail(&out->vb_group, vb); if (fr_redis_reply_to_value_box(vb, vb, reply->element[i], - FR_TYPE_NULL, NULL, box_error, shallow) < 0) goto array_error; + FR_TYPE_VOID, NULL, box_error, shallow) < 0) goto array_error; } } } - if ((dst_type != FR_TYPE_NULL) && (fr_value_box_cast(ctx, out, dst_type, dst_enumv, &in) < 0)) return -1; + if ((dst_type != FR_TYPE_VOID) && (fr_value_box_cast(ctx, out, dst_type, dst_enumv, &in) < 0)) return -1; return 0; } diff --git a/src/modules/rlm_redis/rlm_redis.c b/src/modules/rlm_redis/rlm_redis.c index 778e55bbf7..53e0bbb5b7 100644 --- a/src/modules/rlm_redis/rlm_redis.c +++ b/src/modules/rlm_redis/rlm_redis.c @@ -449,7 +449,7 @@ static xlat_action_t redis_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out, reply_parse: MEM(vb_out = fr_value_box_alloc_null(ctx)); - if (fr_redis_reply_to_value_box(ctx, vb_out, reply, FR_TYPE_NULL, NULL, false, false) < 0) { + if (fr_redis_reply_to_value_box(ctx, vb_out, reply, FR_TYPE_VOID, NULL, false, false) < 0) { RPERROR("Failed processing reply"); return XLAT_ACTION_FAIL; }