for (i = 0, dwrq->length = 0; i < list->count && dwrq->length < IW_MAX_AP; i++) {
bi = bi ? (wl_bss_info_t *)((uintptr)bi + dtoh32(bi->length)) : list->bss_info;
- if ((uintptr)bi >= ((uintptr)list + buflen)) {
- WL_ERROR(("%s: Scan results out of bounds\n",__FUNCTION__));
+
+ if ((dtoh32(bi->length) > buflen) ||
+ (((uintptr)bi + dtoh32(bi->length)) > ((uintptr)list + buflen))) {
+ WL_ERROR(("%s: Scan results out of bounds: %u\n",__FUNCTION__,dtoh32(bi->length)));
kfree(list);
return -E2BIG;
}
for (i = 0, dwrq->length = 0; i < list->count && dwrq->length < IW_MAX_AP; i++) {
bi = bi ? (wl_bss_info_t *)((uintptr)bi + dtoh32(bi->length))
: list->bss_info;
- if ((uintptr)bi >= ((uintptr)list + WLC_IW_ISCAN_MAXLEN)) {
- WL_ERROR(("%s: Scan results out of bounds\n",__FUNCTION__));
+
+ if ((dtoh32(bi->length) > WLC_IW_ISCAN_MAXLEN) ||
+ (((uintptr)bi + dtoh32(bi->length)) > ((uintptr)list + WLC_IW_ISCAN_MAXLEN))) {
+ WL_ERROR(("%s: Scan results out of bounds: %u\n",__FUNCTION__,dtoh32(bi->length)));
return -E2BIG;
}
if (!list) {
WL_ERROR(("%s: Null list pointer",__FUNCTION__));
- return -EINVAL;
+ return ret;
}
for (i = 0; i < list->count && i < IW_MAX_AP; i++)
for (ii = 0; ii < list->count && apcnt < IW_MAX_AP; apcnt++, ii++) {
bi = bi ? (wl_bss_info_t *)((uintptr)bi + dtoh32(bi->length)) : list->bss_info;
- if ((uintptr)bi >= ((uintptr)list + WLC_IW_ISCAN_MAXLEN)) {
- WL_ERROR(("%s: Scan results out of bounds\n",__FUNCTION__));
+ if ((dtoh32(bi->length) > WLC_IW_ISCAN_MAXLEN) ||
+ (((uintptr)bi + dtoh32(bi->length)) > ((uintptr)list + WLC_IW_ISCAN_MAXLEN))) {
+ WL_ERROR(("%s: Scan results out of bounds: %u\n",__FUNCTION__,dtoh32(bi->length)));
return -E2BIG;
}