Message ID | 1226653710-27642-1-git-send-email-remi.denis-courmont@nokia.com |
---|---|
State | Accepted, archived |
Delegated to: | David Miller |
Headers | show |
On Fri, 14 Nov 2008, Rémi Denis-Courmont wrote: > Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com> > --- > net/phonet/af_phonet.c | 4 ++-- > 1 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c > index defeb7a..7ab30f6 100644 > --- a/net/phonet/af_phonet.c > +++ b/net/phonet/af_phonet.c > @@ -144,8 +144,8 @@ static int pn_send(struct sk_buff *skb, struct net_device *dev, > struct phonethdr *ph; > int err; > > - if (skb->len + 2 > 0xffff) { > - /* Phonet length field would overflow */ > + if (skb->len + 2 > 0xffff /* Phonet length field limit */ || It would by much better to have a well named constant there rather than such crazy and messy contruct with a comment.
From: "Ilpo Järvinen" <ilpo.jarvinen@helsinki.fi> Date: Fri, 14 Nov 2008 12:25:40 +0200 (EET) > On Fri, 14 Nov 2008, Rémi Denis-Courmont wrote: > > > Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com> > > --- > > net/phonet/af_phonet.c | 4 ++-- > > 1 files changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c > > index defeb7a..7ab30f6 100644 > > --- a/net/phonet/af_phonet.c > > +++ b/net/phonet/af_phonet.c > > @@ -144,8 +144,8 @@ static int pn_send(struct sk_buff *skb, struct net_device *dev, > > struct phonethdr *ph; > > int err; > > > > - if (skb->len + 2 > 0xffff) { > > - /* Phonet length field would overflow */ > > + if (skb->len + 2 > 0xffff /* Phonet length field limit */ || > > It would by much better to have a well named constant there rather than > such crazy and messy contruct with a comment. Sure, but it would need to be "U16_MAX" or whatever, which we don't have currently, since this is a field overflow check rather than some specific constant defined by the protocol. I'm applying Rémi's patch. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c index defeb7a..7ab30f6 100644 --- a/net/phonet/af_phonet.c +++ b/net/phonet/af_phonet.c @@ -144,8 +144,8 @@ static int pn_send(struct sk_buff *skb, struct net_device *dev, struct phonethdr *ph; int err; - if (skb->len + 2 > 0xffff) { - /* Phonet length field would overflow */ + if (skb->len + 2 > 0xffff /* Phonet length field limit */ || + skb->len + sizeof(struct phonethdr) > dev->mtu) { err = -EMSGSIZE; goto drop; }
Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com> --- net/phonet/af_phonet.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)