@@ -37,6 +37,11 @@ bool ValidateByteRange::getRange(const std::string &rangeRepresentation,
3737 " ' into a number" );
3838 return false ;
3939 }
40+ if ((start < 0 ) || (start > 255 )) {
41+ error->assign (" Invalid range start value: " +
42+ std::to_string (start));
43+ return false ;
44+ }
4045 table[start >> 3 ] = (table[start >> 3 ] | (1 << (start & 0x7 )));
4146 return true ;
4247 }
@@ -60,11 +65,6 @@ bool ValidateByteRange::getRange(const std::string &rangeRepresentation,
6065 return false ;
6166 }
6267
63- if ((start < 0 ) || (start > 255 )) {
64- error->assign (" Invalid range start value: " +
65- std::to_string (start));
66- return false ;
67- }
6868 if ((end < 0 ) || (end > 255 )) {
6969 error->assign (" Invalid range end value: " + std::to_string (end));
7070 return false ;
@@ -87,21 +87,29 @@ bool ValidateByteRange::getRange(const std::string &rangeRepresentation,
8787bool ValidateByteRange::init (const std::string &file,
8888 std::string *error) {
8989 size_t pos = m_param.find_first_of (" ," );
90+ bool rc;
9091
9192 if (pos == std::string::npos) {
92- getRange (m_param, error);
93+ rc = getRange (m_param, error);
9394 } else {
94- getRange (std::string (m_param, 0 , pos), error);
95+ rc = getRange (std::string (m_param, 0 , pos), error);
96+ }
97+
98+ if (rc == false ) {
99+ return false ;
95100 }
96101
97102 while (pos != std::string::npos) {
98103 size_t next_pos = m_param.find_first_of (" ," , pos + 1 );
99104
100105 if (next_pos == std::string::npos) {
101- getRange (std::string (m_param, pos + 1 , m_param.length () -
106+ rc = getRange (std::string (m_param, pos + 1 , m_param.length () -
102107 (pos + 1 )), error);
103108 } else {
104- getRange (std::string (m_param, pos + 1 , next_pos - (pos + 1 )), error);
109+ rc = getRange (std::string (m_param, pos + 1 , next_pos - (pos + 1 )), error);
110+ }
111+ if (rc == false ) {
112+ return false ;
105113 }
106114 pos = next_pos;
107115 }
0 commit comments