@@ -37,6 +37,11 @@ bool ValidateByteRange::getRange(const std::string &rangeRepresentation,
37
37
" ' into a number" );
38
38
return false ;
39
39
}
40
+ if ((start < 0 ) || (start > 255 )) {
41
+ error->assign (" Invalid range start value: " +
42
+ std::to_string (start));
43
+ return false ;
44
+ }
40
45
table[start >> 3 ] = (table[start >> 3 ] | (1 << (start & 0x7 )));
41
46
return true ;
42
47
}
@@ -60,11 +65,6 @@ bool ValidateByteRange::getRange(const std::string &rangeRepresentation,
60
65
return false ;
61
66
}
62
67
63
- if ((start < 0 ) || (start > 255 )) {
64
- error->assign (" Invalid range start value: " +
65
- std::to_string (start));
66
- return false ;
67
- }
68
68
if ((end < 0 ) || (end > 255 )) {
69
69
error->assign (" Invalid range end value: " + std::to_string (end));
70
70
return false ;
@@ -87,21 +87,29 @@ bool ValidateByteRange::getRange(const std::string &rangeRepresentation,
87
87
bool ValidateByteRange::init (const std::string &file,
88
88
std::string *error) {
89
89
size_t pos = m_param.find_first_of (" ," );
90
+ bool rc;
90
91
91
92
if (pos == std::string::npos) {
92
- getRange (m_param, error);
93
+ rc = getRange (m_param, error);
93
94
} 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 ;
95
100
}
96
101
97
102
while (pos != std::string::npos) {
98
103
size_t next_pos = m_param.find_first_of (" ," , pos + 1 );
99
104
100
105
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 () -
102
107
(pos + 1 )), error);
103
108
} 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 ;
105
113
}
106
114
pos = next_pos;
107
115
}
0 commit comments