-/* $OpenBSD: if_iwm.c,v 1.403 2022/07/11 11:28:37 stsp Exp $ */
+/* $OpenBSD: if_iwm.c,v 1.404 2022/08/29 17:59:12 stsp Exp $ */
/*
* Copyright (c) 2014, 2016 genua gmbh <info@genua.de>
goto parse_out;
}
+ /*
+ * Check for size_t overflow and ignore missing padding at
+ * end of firmware file.
+ */
+ if (roundup(tlv_len, 4) > len)
+ break;
+
len -= roundup(tlv_len, 4);
data += roundup(tlv_len, 4);
}
-/* $OpenBSD: if_iwx.c,v 1.149 2022/05/14 05:42:39 stsp Exp $ */
+/* $OpenBSD: if_iwx.c,v 1.150 2022/08/29 17:59:12 stsp Exp $ */
/*
* Copyright (c) 2014, 2016 genua gmbh <info@genua.de>
goto parse_out;
}
+ /*
+ * Check for size_t overflow and ignore missing padding at
+ * end of firmware file.
+ */
+ if (roundup(tlv_len, 4) > len)
+ break;
+
len -= roundup(tlv_len, 4);
data += roundup(tlv_len, 4);
}
break;
}
+ if (roundup(tlv_len, 4) > len)
+ break;
len -= roundup(tlv_len, 4);
data += roundup(tlv_len, 4);
}
tlv_len = le32toh(tlv->length);
tlv_type = le32toh(tlv->type);
- if (len < tlv_len)
+ if (len < tlv_len || roundup(tlv_len, 4) > len)
return EINVAL;
if (tlv_type == IWX_UCODE_TLV_PNVM_SKU) {