@@ -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 byte 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
}
@@ -87,21 +92,29 @@ bool ValidateByteRange::getRange(const std::string &rangeRepresentation,
87
92
bool ValidateByteRange::init (const std::string &file,
88
93
std::string *error) {
89
94
size_t pos = m_param.find_first_of (" ," );
95
+ bool rc;
90
96
91
97
if (pos == std::string::npos) {
92
- getRange (m_param, error);
98
+ rc = getRange (m_param, error);
93
99
} else {
94
- getRange (std::string (m_param, 0 , pos), error);
100
+ rc = getRange (std::string (m_param, 0 , pos), error);
101
+ }
102
+
103
+ if (rc == false ) {
104
+ return false ;
95
105
}
96
106
97
107
while (pos != std::string::npos) {
98
108
size_t next_pos = m_param.find_first_of (" ," , pos + 1 );
99
109
100
110
if (next_pos == std::string::npos) {
101
- getRange (std::string (m_param, pos + 1 , m_param.length () -
111
+ rc = getRange (std::string (m_param, pos + 1 , m_param.length () -
102
112
(pos + 1 )), error);
103
113
} else {
104
- getRange (std::string (m_param, pos + 1 , next_pos - (pos + 1 )), error);
114
+ rc = getRange (std::string (m_param, pos + 1 , next_pos - (pos + 1 )), error);
115
+ }
116
+ if (rc == false ) {
117
+ return false ;
105
118
}
106
119
pos = next_pos;
107
120
}
0 commit comments