Skip to content

Commit 0ec2b39

Browse files
committed
manual port of commit 5906bfa
1 parent 7909350 commit 0ec2b39

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/lib/filters.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,13 +1205,19 @@ void print_abinary(char *out, size_t outlen, uint8_t const *data, size_t len, in
12051205
}
12061206
}
12071207
} else if (filter->type == RAD_FILTER_GENERIC) {
1208-
int count;
1208+
size_t count, masklen;
1209+
1210+
masklen = ntohs(filter->u.generic.len);
1211+
if (masklen >= sizeof(filter->u.generic.mask)) {
1212+
*p = '\0';
1213+
return;
1214+
}
12091215

12101216
i = snprintf(p, outlen, " %u ", (unsigned int) ntohs(filter->u.generic.offset));
12111217
p += i;
12121218

12131219
/* show the mask */
1214-
for (count = 0; count < ntohs(filter->u.generic.len); count++) {
1220+
for (count = 0; count < masklen; count++) {
12151221
i = snprintf(p, outlen, "%02x", filter->u.generic.mask[count]);
12161222
p += i;
12171223
outlen -= i;
@@ -1222,7 +1228,7 @@ void print_abinary(char *out, size_t outlen, uint8_t const *data, size_t len, in
12221228
outlen--;
12231229

12241230
/* show the value */
1225-
for (count = 0; count < ntohs(filter->u.generic.len); count++) {
1231+
for (count = 0; count < masklen; count++) {
12261232
i = snprintf(p, outlen, "%02x", filter->u.generic.value[count]);
12271233
p += i;
12281234
outlen -= i;

0 commit comments

Comments
 (0)