Merge branch 'master' into hj_rt
authorheejin-kim <hj_elena.kim@samsung.com>
Mon, 17 Jul 2017 06:46:03 +0000 (15:46 +0900)
committerGitHub <noreply@github.com>
Mon, 17 Jul 2017 06:46:03 +0000 (15:46 +0900)
1  2 
apps/netutils/webserver/http_client.c

@@@ -480,8 -513,12 +480,10 @@@ void http_handle_file(struct http_clien
                /* Need to create file with unique file name */
                strncat(path, url, HTTP_CONF_MAX_REQUEST_HEADER_URL_LENGTH);
                strncat(path, "index.shtml", HTTP_CONF_MAX_REQUEST_HEADER_URL_LENGTH);
 -              if ((f = fopen(path, "w"))) {
 -                      if (fputs(entity, f) < 0) {
 -                              HTTP_LOGE("Error: Fail to execute fputs\n");
 -                              fclose(f);
 -                              break;
 -                      }
++
 +              if (valid && (f = fopen(path, "w"))) {
 +                      fputs(entity, f);
++
                        if (http_send_response(client, 200, path, NULL) == HTTP_ERROR) {
                                HTTP_LOGE("Error: Fail to send response\n");
                        }
                }
                break;
        case HTTP_METHOD_PUT:
 -              if ((f = fopen(strncat(path, url, HTTP_CONF_MAX_REQUEST_HEADER_URL_LENGTH), "w"))) {
 -                      if (fputs(entity, f) < 0) {
 -                              HTTP_LOGE("Error: Fail to execute fputs\n");
 -                              fclose(f);
 -                              break;
 -                      }
 +              ref = strlen(url) + 1;
 +              if (ref > HTTP_CONF_MAX_REQUEST_HEADER_URL_LENGTH) {
 +                      valid = 0;
 +                      HTTP_LOGE("ERROR: URL length is too long. Cannot send response\n");
 +              } else
 +                      valid = 1;
 +              if (valid && (f = fopen(strncat(path, url, HTTP_CONF_MAX_REQUEST_HEADER_URL_LENGTH), "w"))) {
 +                      fputs(entity, f);
++
                        if (http_send_response(client, 200, url, NULL) == HTTP_ERROR) {
                                HTTP_LOGE("Error: Fail to send response\n");
                        }