@@ -845,6 +845,7 @@ static void HTTPsReq_MethodParse (HTTPs_INSTANCE *p_instance,
845
845
CPU_CHAR * p_request_method_start ;
846
846
CPU_CHAR * p_request_method_end ;
847
847
CPU_SIZE_T len ;
848
+ CPU_SIZE_T skipped_chars ;
848
849
HTTPs_INSTANCE_STATS * p_ctr_stats ;
849
850
CPU_INT32U method ;
850
851
@@ -857,26 +858,32 @@ static void HTTPsReq_MethodParse (HTTPs_INSTANCE *p_instance,
857
858
* p_err = HTTPs_ERR_REQ_FORMAT_INVALID ;
858
859
return ;
859
860
}
860
- /* Move the start ptr to the first meanningful char. */
861
+ /* Move the start ptr to the first printable ASCII char.*/
861
862
p_request_method_start = HTTP_StrGraphSrchFirst (p_conn -> RxBufPtr , len );
862
863
if (p_request_method_start == DEF_NULL ) {
863
864
* p_err = HTTPs_ERR_REQ_FORMAT_INVALID ;
864
865
return ;
865
866
}
866
- len -= p_request_method_start - p_conn -> RxBufPtr ;
867
+
868
+ skipped_chars = p_request_method_start - p_conn -> RxBufPtr ;
869
+
870
+ len -= skipped_chars ; /* Disregard illegal, non-printable ASCII characters. */
867
871
/* Find the end of method string. */
868
872
p_request_method_end = Str_Char_N (p_request_method_start , len , ASCII_CHAR_SPACE );
869
873
if (p_request_method_end == DEF_NULL ) {
870
874
* p_err = HTTPs_ERR_REQ_FORMAT_INVALID ;
871
875
return ;
872
876
}
873
- len = p_request_method_end - p_request_method_start ;
877
+
878
+ p_conn -> RxBufLenRem -= skipped_chars ; /* Update RxBufLenRem to reflect nbr of skipped chars. */
879
+
880
+ len = p_request_method_end - p_request_method_start ;
874
881
/* Try to match the Method str received. */
875
- method = HTTP_Dict_KeyGet (HTTP_Dict_ReqMethod ,
876
- HTTP_Dict_ReqMethodSize ,
877
- p_request_method_start ,
878
- DEF_YES ,
879
- len );
882
+ method = HTTP_Dict_KeyGet (HTTP_Dict_ReqMethod ,
883
+ HTTP_Dict_ReqMethodSize ,
884
+ p_request_method_start ,
885
+ DEF_YES ,
886
+ len );
880
887
/* Validate the DictionaryKey search results */
881
888
if (method == HTTP_DICT_KEY_INVALID ) {
882
889
p_conn -> Method = HTTP_METHOD_UNKNOWN ;
@@ -1362,6 +1369,7 @@ static void HTTPsReq_ProtocolVerParse (HTTPs_INSTANCE *p_instance,
1362
1369
CPU_CHAR * p_protocol_ver_end ;
1363
1370
CPU_INT32U len ;
1364
1371
CPU_INT32U protocol_ver ;
1372
+ CPU_SIZE_T skipped_chars ;
1365
1373
HTTPs_INSTANCE_STATS * p_ctr_stats ;
1366
1374
1367
1375
@@ -1375,11 +1383,18 @@ static void HTTPsReq_ProtocolVerParse (HTTPs_INSTANCE *p_instance,
1375
1383
/* Move the pointer to the next meaningful char. */
1376
1384
p_protocol_ver_start = HTTP_StrGraphSrchFirst (p_conn -> RxBufPtr , len );
1377
1385
if (p_protocol_ver_start == DEF_NULL ) {
1378
- * p_err = HTTPs_ERR_REQ_FORMAT_INVALID ;
1386
+ * p_err = HTTPs_ERR_REQ_FORMAT_INVALID ;
1379
1387
return ;
1380
1388
}
1389
+
1390
+ skipped_chars = p_protocol_ver_start - p_conn -> RxBufPtr ;
1391
+
1392
+ len -= skipped_chars ; /* Disregard illegal, non-printable ASCII characters. */
1381
1393
/* Find the end of the request line. */
1382
- p_protocol_ver_end = Str_Str_N (p_protocol_ver_start , STR_CR_LF , len );
1394
+ p_protocol_ver_end = Str_Str_N (p_protocol_ver_start , STR_CR_LF , len );
1395
+ /* Update RxBufLenRem to reflect nbr of skipped chars. */
1396
+ p_conn -> RxBufLenRem -= skipped_chars ;
1397
+
1383
1398
if (p_protocol_ver_end == DEF_NULL ) { /* If not found, check to get more data. */
1384
1399
if (p_conn -> RxBufPtr != p_conn -> BufPtr ) {
1385
1400
* p_err = HTTPs_ERR_REQ_MORE_DATA_REQUIRED ;
0 commit comments