diff --git a/sys/netgraph7/ng_source.c b/sys/netgraph7/ng_source.c --- a/sys/netgraph7/ng_source.c +++ b/sys/netgraph7/ng_source.c @@ -478,9 +478,15 @@ } case NGM_SOURCE_GET_COUNTER: { - uint8_t index = *(uint8_t *)msg->data; + uint8_t index; struct ng_source_embed_cnt_info *embed; + if (msg->header.arglen < sizeof(index)) { + error = EINVAL; + goto done; + } + index = *(uint8_t *)msg->data; + if (index >= NG_SOURCE_COUNTERS) { error = EINVAL; goto done;