sctp: validate from_addr_param return
[sfrench/cifs-2.6.git] / net / sctp / sm_make_chunk.c
index 5b44d228b6cacc720300d9f5951115a95a828163..f33a870b483da7123e2ddb4473b6200a1aca5ade 100644 (file)
@@ -2346,11 +2346,13 @@ int sctp_process_init(struct sctp_association *asoc, struct sctp_chunk *chunk,
 
        /* Process the initialization parameters.  */
        sctp_walk_params(param, peer_init, init_hdr.params) {
-               if (!src_match && (param.p->type == SCTP_PARAM_IPV4_ADDRESS ||
-                   param.p->type == SCTP_PARAM_IPV6_ADDRESS)) {
+               if (!src_match &&
+                   (param.p->type == SCTP_PARAM_IPV4_ADDRESS ||
+                    param.p->type == SCTP_PARAM_IPV6_ADDRESS)) {
                        af = sctp_get_af_specific(param_type2af(param.p->type));
-                       af->from_addr_param(&addr, param.addr,
-                                           chunk->sctp_hdr->source, 0);
+                       if (!af->from_addr_param(&addr, param.addr,
+                                                chunk->sctp_hdr->source, 0))
+                               continue;
                        if (sctp_cmp_addr_exact(sctp_source(chunk), &addr))
                                src_match = 1;
                }
@@ -2531,7 +2533,8 @@ static int sctp_process_param(struct sctp_association *asoc,
                        break;
 do_addr_param:
                af = sctp_get_af_specific(param_type2af(param.p->type));
-               af->from_addr_param(&addr, param.addr, htons(asoc->peer.port), 0);
+               if (!af->from_addr_param(&addr, param.addr, htons(asoc->peer.port), 0))
+                       break;
                scope = sctp_scope(peer_addr);
                if (sctp_in_scope(net, &addr, scope))
                        if (!sctp_assoc_add_peer(asoc, &addr, gfp, SCTP_UNCONFIRMED))
@@ -2632,15 +2635,13 @@ do_addr_param:
                addr_param = param.v + sizeof(struct sctp_addip_param);
 
                af = sctp_get_af_specific(param_type2af(addr_param->p.type));
-               if (af == NULL)
+               if (!af)
                        break;
 
-               af->from_addr_param(&addr, addr_param,
-                                   htons(asoc->peer.port), 0);
+               if (!af->from_addr_param(&addr, addr_param,
+                                        htons(asoc->peer.port), 0))
+                       break;
 
-               /* if the address is invalid, we can't process it.
-                * XXX: see spec for what to do.
-                */
                if (!af->addr_valid(&addr, NULL, NULL))
                        break;
 
@@ -3054,7 +3055,8 @@ static __be16 sctp_process_asconf_param(struct sctp_association *asoc,
        if (unlikely(!af))
                return SCTP_ERROR_DNS_FAILED;
 
-       af->from_addr_param(&addr, addr_param, htons(asoc->peer.port), 0);
+       if (!af->from_addr_param(&addr, addr_param, htons(asoc->peer.port), 0))
+               return SCTP_ERROR_DNS_FAILED;
 
        /* ADDIP 4.2.1  This parameter MUST NOT contain a broadcast
         * or multicast address.
@@ -3331,7 +3333,8 @@ static void sctp_asconf_param_success(struct sctp_association *asoc,
 
        /* We have checked the packet before, so we do not check again. */
        af = sctp_get_af_specific(param_type2af(addr_param->p.type));
-       af->from_addr_param(&addr, addr_param, htons(bp->port), 0);
+       if (!af->from_addr_param(&addr, addr_param, htons(bp->port), 0))
+               return;
 
        switch (asconf_param->param_hdr.type) {
        case SCTP_PARAM_ADD_IP: