Discussion:
Unchecked function return value
(too old to reply)
Loganaden Velvindron
2013-10-04 06:26:18 UTC
Permalink
Hi All,

In ip6_input.c:

in6_setscope() returns 0 on success.

This was checked at other places:

472 if (in6_setscope(&ip6->ip6_src, m->m_pkthdr.rcvif, NULL) ||
473 in6_setscope(&ip6->ip6_dst, m->m_pkthdr.rcvif, NULL)) {
474 IP6_STATINC(IP6_STAT_BADSCOPE);
475 goto bad;
476 }
477

Index: src/sys/netinet6/ip6_input.c
===================================================================
RCS file: /cvsroot/src/sys/netinet6/ip6_input.c,v
retrieving revision 1.143
diff -u -p -r1.143 ip6_input.c
--- src/sys/netinet6/ip6_input.c 29 Jun 2013 21:06:58 -0000 1.143
+++ src/sys/netinet6/ip6_input.c 4 Oct 2013 06:19:52 -0000
@@ -812,7 +812,9 @@ ip6_setdstifaddr(struct mbuf *m, const s
struct ip6aux *ip6a;

ip6a = (struct ip6aux *)(mtag + 1);
- in6_setscope(&ip6a->ip6a_src, ia->ia_ifp, &ip6a->ip6a_scope_id);
+ if (in6_setscope(&ip6a->ip6a_src, ia->ia_ifp, &ip6a->ip6a_scope_id)) {
+ return NULL;
+ }
ip6a->ip6a_src = ia->ia_addr.sin6_addr;
ip6a->ip6a_flags = ia->ia6_flags;
}

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Christos Zoulas
2013-10-04 14:23:22 UTC
Permalink
Post by Loganaden Velvindron
Hi All,
in6_setscope() returns 0 on success.
472 if (in6_setscope(&ip6->ip6_src, m->m_pkthdr.rcvif, NULL) ||
473 in6_setscope(&ip6->ip6_dst, m->m_pkthdr.rcvif, NULL)) {
474 IP6_STATINC(IP6_STAT_BADSCOPE);
475 goto bad;
476 }
477
Index: src/sys/netinet6/ip6_input.c
===================================================================
RCS file: /cvsroot/src/sys/netinet6/ip6_input.c,v
retrieving revision 1.143
diff -u -p -r1.143 ip6_input.c
--- src/sys/netinet6/ip6_input.c 29 Jun 2013 21:06:58 -0000 1.143
+++ src/sys/netinet6/ip6_input.c 4 Oct 2013 06:19:52 -0000
@@ -812,7 +812,9 @@ ip6_setdstifaddr(struct mbuf *m, const s
struct ip6aux *ip6a;
ip6a = (struct ip6aux *)(mtag + 1);
- in6_setscope(&ip6a->ip6a_src, ia->ia_ifp, &ip6a->ip6a_scope_id);
+ if (in6_setscope(&ip6a->ip6a_src, ia->ia_ifp, &ip6a->ip6a_scope_id)) {
+ return NULL;
+ }
ip6a->ip6a_src = ia->ia_addr.sin6_addr;
ip6a->ip6a_flags = ia->ia6_flags;
Fixed.

christos


--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Loading...