if (scanf("%d", &total_num) < 0)
return -1;
+ if (total_num < 0 || total_num > MAX_MATCH_FILTER_LEN) {
+ printf("Too many match filters");
+ return -1;
+ }
for (int i = 0; i < total_num; ++i) {
printf("%d match filter len: ", i);
if (scanf("%d", &len) < 0)
printf("The length of filter value is not %d\n", len);
return -1;
}
+ if (total_len > MAX_MATCH_FILTER_LEN) {
+ printf("The length of filter value is longer than max length(%d)", MAX_MATCH_FILTER_LEN);
+ return -1;
+ }
+ if (total_len + len > MAX_MATCH_FILTER_LEN) {
+ printf("The length of filter value is longer than max length(%d)", MAX_MATCH_FILTER_LEN);
+ return -1;
+ }
match_filter[total_len++] = len;
memcpy(&match_filter[total_len], filter, len);
total_len += len;
ret = scanf("%d", &set_mf);
if (set_mf == 1) {
len = __set_match_filter(match_filter);
- if (len < 0) {
+ if (len < 0 || len >= MAX_MATCH_FILTER_LEN) {
printf("Not set match filter\n");
return;
}
ret = scanf("%d", &set_mf);
if (set_mf == 1) {
len = __set_match_filter(match_filter);
- if (len < 0) {
+ if (len < 0 || len >= MAX_MATCH_FILTER_LEN) {
printf("Not set match filter\n");
return;
}