Check a number of HTTP header fields 59/175759/6 accepted/tizen/unified/20180413.073633 submit/tizen/20180413.011058
authorSeonah Moon <seonah1.moon@samsung.com>
Thu, 12 Apr 2018 06:46:50 +0000 (15:46 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Thu, 12 Apr 2018 07:03:42 +0000 (16:03 +0900)
The standard imposes no limits to the number of fields.
However, generally, most servers limit it.

Change-Id: I99388a2c3e534c4cc45c648fd54827a2fc826012

provider-interface/download-provider-interface.c

index 52f09ab..c03ff17 100755 (executable)
@@ -63,6 +63,7 @@
 } while (0)
 
 #define DOWNLOAD_FILENAME_MAX 256
+#define DOWNLOAD_HTTP_HEADER_FIELDS_MAX 200
 
 #ifndef SIZE_MAX
 #define SIZE_MAX ((size_t) -1)
@@ -1541,12 +1542,16 @@ int dp_interface_get_http_header_field_list(const int id, char ***fields,
                                if (dp_ipc_read(sock, &array_size, extra_size, __FUNCTION__) < 0) {
                                        errorcode = DP_ERROR_IO_ERROR;
                                } else {
-                                       if (array_size <= 0 && array_size >= SIZE_MAX) {
+                                       if (array_size <= 0) {
                                                errorcode = DP_ERROR_NO_DATA;
                                                *length = 0;
                                        } else {
                                                int i = 0;
                                                char **recv_strings = NULL;
+
+                                               if (array_size > DOWNLOAD_HTTP_HEADER_FIELDS_MAX)
+                                                       array_size = DOWNLOAD_HTTP_HEADER_FIELDS_MAX;
+
                                                recv_strings = (char **)calloc(array_size, sizeof(char *));
                                                if (recv_strings == NULL) {
                                                        TRACE_ERROR("check memory size:%d", array_size);