-/* $OpenBSD: l2tp_subr.c,v 1.4 2012/05/08 13:15:11 yasuoka Exp $ */
+/* $OpenBSD: l2tp_subr.c,v 1.5 2023/09/11 07:33:07 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* $Id: l2tp_subr.c,v 1.4 2012/05/08 13:15:11 yasuoka Exp $ */
+/* $Id: l2tp_subr.c,v 1.5 2023/09/11 07:33:07 yasuoka Exp $ */
/**@file L2TP related sub-routines */
#include <sys/types.h>
#include <sys/time.h>
avp->attr_type |= *(pkt + 1);
pkt += 2;
- if (avp->length > pktlen)
+ if (avp->length < 6 || avp->length > pktlen)
return -1;
- if (filldata != 0)
+ if (avp->length > 6 && filldata != 0)
memcpy(avp->attr_value, pkt, avp->length - 6);
return avp->length;
while (pktlen >= 6 &&
(avpsz = avp_enum(avp, pkt, pktlen, fill_data)) > 0) {
+ L2TP_SUBR_ASSERT(avpsz >= 6);
if (avp->vendor_id != vendor_id || avp->attr_type != attr_type) {
- if (avpsz < 6)
- return NULL;
pkt += avpsz;
pktlen -= avpsz;
continue;