Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
fix gcc8 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
bui committed Nov 23, 2018
1 parent d9bfac6 commit 097a1e9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions naxsi_src/naxsi_runtime.c
Expand Up @@ -733,10 +733,10 @@ ngx_http_dummy_is_rule_whitelisted_n(ngx_http_request_t *req,
tmp_hashname.data = ngx_pcalloc(req->pool, tmp_hashname.len+2);
if (target_name) {
tmp_hashname.len++;
strncat((char*)tmp_hashname.data, "#", 1);
strcat((char*)tmp_hashname.data, "#");
}
strncat((char*) tmp_hashname.data, (char*)req->uri.data, req->uri.len);
strncat((char*)tmp_hashname.data, "#", 1);
strcat((char*)tmp_hashname.data, "#");
strncat((char*)tmp_hashname.data, (char*)name->data, name->len);

NX_DEBUG(_debug_whitelist_compat, NGX_LOG_DEBUG_HTTP, req->connection->log, 0, "hashing MIX [%V] ($URL:x|$X_VAR:y) or ($URL:x|$X_VAR:y|NAME)", &tmp_hashname);
Expand Down
5 changes: 5 additions & 0 deletions naxsi_src/naxsi_skeleton.c
Expand Up @@ -414,8 +414,13 @@ ngx_http_dummy_init(ngx_conf_t *cf)
libjct_sql->sc_tag->data = ngx_pcalloc(cf->pool, 18 /* LIBINJECTION_SQL */);
libjct_xss->sc_tag->data = ngx_pcalloc(cf->pool, 18 /* LIBINJECTION_XSS */);
if (!libjct_sql->sc_tag->data || !libjct_xss->sc_tag->data) return (NGX_ERROR); /* LCOV_EXCL_LINE */
/* avoid stringop-truncation false positive.
nginx_str_t is not null terminated */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-truncation"
strncpy((char *)libjct_sql->sc_tag->data, (char *)"$LIBINJECTION_SQL", 17);
strncpy((char *)libjct_xss->sc_tag->data, (char *)"$LIBINJECTION_XSS", 17);
#pragma GCC diagnostic pop
libjct_xss->sc_tag->len = 17;
libjct_sql->sc_tag->len = 17;
libjct_sql->sc_score = 8;
Expand Down
8 changes: 4 additions & 4 deletions naxsi_src/naxsi_utils.c
Expand Up @@ -455,11 +455,11 @@ ngx_http_wlr_find(ngx_conf_t *cf, ngx_http_dummy_loc_conf_t *dlc,
"whitelist targets |NAME");


strncat(*fullname, (const char *) "#", 1);
strcat(*fullname, (const char *) "#");
}
strncat(*fullname, (const char *) custloc_array(curr->br->custom_locations->elts)[uri_idx].target.data,
custloc_array(curr->br->custom_locations->elts)[uri_idx].target.len);
strncat(*fullname, (const char *) "#", 1);
strcat(*fullname, (const char *) "#");
strncat(*fullname, (const char *) custloc_array(curr->br->custom_locations->elts)[name_idx].target.data,
custloc_array(curr->br->custom_locations->elts)[name_idx].target.len);
}
Expand All @@ -477,7 +477,7 @@ ngx_http_wlr_find(ngx_conf_t *cf, ngx_http_dummy_loc_conf_t *dlc,
"whitelist targets |NAME");


strncat(*fullname, (const char *) "#", 1);
strcat(*fullname, (const char *) "#");
}


Expand All @@ -492,7 +492,7 @@ ngx_http_wlr_find(ngx_conf_t *cf, ngx_http_dummy_loc_conf_t *dlc,

*fullname = ngx_pcalloc(cf->pool, custloc_array(curr->br->custom_locations->elts)[name_idx].target.len + 2);
if (curr->br->target_name)
strncat(*fullname, (const char *) "#", 1);
strcat(*fullname, (const char *) "#");
strncat(*fullname, (const char *) custloc_array(curr->br->custom_locations->elts)[name_idx].target.data,
custloc_array(curr->br->custom_locations->elts)[name_idx].target.len);
}
Expand Down

0 comments on commit 097a1e9

Please sign in to comment.