/* 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");
}