Skip to content

Commit

Permalink
added msglen validation for mipsock output.
Browse files Browse the repository at this point in the history
  • Loading branch information
keiichi committed Feb 13, 2007
1 parent a6eee29 commit 05aef63
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions kame/sys/net/mipsock.c
@@ -1,4 +1,4 @@
/* $Id: mipsock.c,v 1.25 2007/01/26 09:50:56 keiichi Exp $ */ /* $Id: mipsock.c,v 1.26 2007/02/13 02:17:02 keiichi Exp $ */


/* /*
* Copyright (C) 2004 WIDE Project. * Copyright (C) 2004 WIDE Project.
Expand Down Expand Up @@ -392,7 +392,7 @@ mips_output(m, va_alist)
#endif #endif
#endif #endif
{ {
int error = 0; int len, error = 0;
struct mip_msghdr *miph = NULL; struct mip_msghdr *miph = NULL;
struct mipm_bc_info *mipc = NULL; struct mipm_bc_info *mipc = NULL;
struct mipm_nodetype_info *mipmni = NULL; struct mipm_nodetype_info *mipmni = NULL;
Expand All @@ -406,6 +406,16 @@ mips_output(m, va_alist)
u_int16_t bid = 0; u_int16_t bid = 0;


#define senderr(e) do { error = e; goto flush;} while (/*CONSTCOND*/ 0) #define senderr(e) do { error = e; goto flush;} while (/*CONSTCOND*/ 0)
if (m == 0 || ((m->m_len < sizeof(int32_t)) &&
(m = m_pullup(m, sizeof(int32_t))) == 0))
return (ENOBUFS);
if ((m->m_flags & M_PKTHDR) == 0)
panic("mips_output");
len = m->m_pkthdr.len;
if (len < sizeof(struct mip_msghdr) ||
len != mtod(m, struct mip_msghdr *)->miph_msglen) {
senderr(EINVAL);
}
miph = mtod(m, struct mip_msghdr *); miph = mtod(m, struct mip_msghdr *);


/* /*
Expand Down

0 comments on commit 05aef63

Please sign in to comment.