@cryptotaxi247 / netdata-1 / commits / 2db6d758f

Fix crash in malloc (#6583)

* Server Crashing: URL search path The system was setting NULL in an address without to have the values * Server Crashing: URL script After to fix the SSL, the script were not 100% compatible, so I am bringing the solution here * Server Crashing: Fixes reported in the issue related a possible NULL value to be kept and wrong variable * Server Crashing: Readable code and missing if It was a missing if yet, so I changed it, no less important I inverted the check order inside if to be more readable

thiagoftsm committed Aug 1, 2019 at 15:05 UTC 2db6d758f843fbf6f50f303e6a704deeff3bcc8e
2 files changed +9 -10
tests/urls/request.sh.in
+4 -6
@@ -212,7 +212,7 @@ netdata_create_directory $OUTEDIR
212 netdata_create_directory $OUTOPTDIR
213 netdata_create_directory $ERRDIR
214
215 -wget --execute="robots = off" --mirror --convert-links --no-parent http://127.0.0.1:19999
215 +wget --no-check-certificate --execute="robots = off" --mirror --convert-links --no-parent $MURL
216 TEST=$?
217 if [ $TEST -ne "0" ] ; then
218 echo "Cannot connect to Netdata"
@@ -232,9 +232,9 @@ netdata_download_various_with_options $MURL "api/v1/info" "info"
232 netdata_download_various $MURL "api/v1/info?this%20could%20not%20be%20here" "err_info"
233
234 netdata_print_header "Getting all the netdata charts"
235 -CHARTS=$( netdata_download_charts "http://127.0.0.1:19999" "api/v1/charts" )
236 -WCHARTS=$( netdata_download_charts "http://127.0.0.1:19999" "api/v1/charts?this%20could%20not%20be%20here" )
237 -WCHARTS2=$( netdata_download_charts "http://127.0.0.1:19999" "api/v1/charts%3fthis%20could%20not%20be%20here" )
235 +CHARTS=$( netdata_download_charts "$MURL" "api/v1/charts" )
236 +WCHARTS=$( netdata_download_charts "$MURL" "api/v1/charts?this%20could%20not%20be%20here" )
237 +WCHARTS2=$( netdata_download_charts "$MURL" "api/v1/charts%3fthis%20could%20not%20be%20here" )
238
239 if [ ${#CHARTS[@]} -ne ${#WCHARTS[@]} ]; then
240 echo "The number of charts does not match with division not encoded.";
@@ -295,8 +295,6 @@ for I in $CHARTS ; do
295 break;
296 done
297
298 -#http://arch-esxi:19999/api/v1/(*@&$!$%%5E)!$*%&)!$*%%5E*!%5E%!%5E$%!%5E%(!*%5E*%5E%(*@&$%5E%(!%5E#*&!^#$*&!^%)@($%^)!*&^(!*&^#$&#$)!$%^)!$*%&)#$!^#*$^!(*#^#)!%^!)$*%&!(*&$!^#$*&^!*#^$!*^)%(!*&$%)(!&#$!^*#&$^!*^%)!$%)!(&#$!^#*&^$
299 -
298 WHITE='\033[0;37m'
299 echo -e "${WHITE}ALL the URLS got 200 as answer!"
300
web/server/web_client.c
+5 -4
@@ -929,7 +929,6 @@ void web_client_split_path_query(struct web_client *w, char *s) {
929
930 w->separator = 0x00;
931 w->url_path_length = strlen(s);
932 - w->url_search_path = NULL;
932 }
933
934 /**
@@ -1035,20 +1034,22 @@ static inline HTTP_VALIDATION http_request_validate(struct web_client *w) {
1034 // a valid complete HTTP request found
1035
1036 *ue = '\0';
1037 + //This is to avoid crash in line
1038 + w->url_search_path = NULL;
1039 if(w->mode != WEB_CLIENT_MODE_NORMAL) {
1040 if(!url_decode_r(w->decoded_url, encoded_url, NETDATA_WEB_REQUEST_URL_SIZE + 1))
1041 return HTTP_VALIDATION_MALFORMED_URL;
1042 } else {
1043 web_client_split_path_query(w, encoded_url);
1044
1044 - if (w->separator) {
1045 + if (w->url_search_path && w->separator) {
1046 *w->url_search_path = 0x00;
1047 }
1048
1049 if(!url_decode_r(w->decoded_url, encoded_url, NETDATA_WEB_REQUEST_URL_SIZE + 1))
1050 return HTTP_VALIDATION_MALFORMED_URL;
1051
1051 - if (w->separator) {
1052 + if (w->url_search_path && w->separator) {
1053 *w->url_search_path = w->separator;
1054
1055 char *from = (encoded_url + w->url_path_length);
@@ -1064,7 +1065,7 @@ static inline HTTP_VALIDATION http_request_validate(struct web_client *w) {
1065 // copy the URL - we are going to overwrite parts of it
1066 // TODO -- ideally we we should avoid copying buffers around
1067 strncpyz(w->last_url, w->decoded_url, NETDATA_WEB_REQUEST_URL_SIZE);
1067 - if (w->separator) {
1068 + if (w->url_search_path && w->separator) {
1069 *w->url_search_path = 0x00;
1070 }
1071 #ifdef ENABLE_HTTPS