Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional checks #8

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/vmod_querymodifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,9 @@ static int tokenize_querystring(VRT_CTX, query_param_t **result,

*result = NULL;

if (query_str == NULL) {
VRT_fail(ctx, "query_str is NULL");
*result = NULL;
return -1;
}
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->ws, WS_MAGIC);
AN(query_str);

query_param_t *params_array =
WS_Alloc(ctx->ws, MAX_QUERY_PARAMS * sizeof(query_param_t));
Expand Down Expand Up @@ -88,6 +86,9 @@ static int parse_filter_params(VRT_CTX, const char *params_in,
char *params_copy;
size_t count = 0;

CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->ws, WS_MAGIC);

if (params_in == NULL || *params_in == '\0') {
*num_filter_params = 0;
return 0;
Expand Down Expand Up @@ -157,6 +158,12 @@ static char *rebuild_query_string(VRT_CTX, const char *uri_base,
struct vsb *vsb = VSB_new_auto();
char sep = '?';

CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->ws, WS_MAGIC);
AN(uri_base);
AN(params);
AN(filter_params);

if (vsb == NULL) {
VRT_fail(ctx, "VSB_new_auto failed");
return NULL;
Expand Down Expand Up @@ -210,6 +217,7 @@ VCL_STRING
vmod_modifyparams(VRT_CTX, VCL_STRING uri, VCL_STRING params_in,
VCL_BOOL exclude_params) {
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->ws, WS_MAGIC);

// Return if the URI is NULL
if (uri == NULL) {
Expand Down
Loading