mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-01-27 03:35:38 +00:00
Multiple fixes found by coverity scan
This commit is contained in:
parent
88a57dc98d
commit
e4ddd6cb6d
@ -314,7 +314,7 @@ lwip_getaddrinfo(const char *nodename, const char *servname,
|
||||
total_size <= NETDB_ELEM_SIZE);
|
||||
ai = (struct addrinfo *)memp_malloc(MEMP_NETDB);
|
||||
if (ai == NULL) {
|
||||
goto memerr;
|
||||
return EAI_MEMORY;
|
||||
}
|
||||
memset(ai, 0, total_size);
|
||||
sa = (struct sockaddr_in*)((u8_t*)ai + sizeof(struct addrinfo));
|
||||
@ -343,11 +343,6 @@ lwip_getaddrinfo(const char *nodename, const char *servname,
|
||||
*res = ai;
|
||||
|
||||
return 0;
|
||||
memerr:
|
||||
if (ai != NULL) {
|
||||
memp_free(MEMP_NETDB, ai);
|
||||
}
|
||||
return EAI_MEMORY;
|
||||
}
|
||||
|
||||
#endif /* LWIP_DNS && LWIP_SOCKET */
|
||||
|
@ -704,6 +704,9 @@ igmp_start_timer(struct igmp_group *group, u8_t max_time)
|
||||
}
|
||||
/* ensure the random value is > 0 */
|
||||
group->timer = (LWIP_RAND() % max_time);
|
||||
if (group->timer == 0) {
|
||||
group->timer = 1;
|
||||
}
|
||||
#else /* LWIP_RAND */
|
||||
/* ATTENTION: use this only if absolutely necessary! */
|
||||
group->timer = max_time / 2;
|
||||
|
@ -496,7 +496,10 @@ mld6_delayed_report(struct mld_group *group, u16_t maxresp)
|
||||
|
||||
#ifdef LWIP_RAND
|
||||
/* Randomize maxresp. (if LWIP_RAND is supported) */
|
||||
maxresp = (LWIP_RAND() % (maxresp - 1)) + 1;
|
||||
maxresp = LWIP_RAND() % maxresp;
|
||||
if (maxresp == 0) {
|
||||
maxresp = 1;
|
||||
}
|
||||
#endif /* LWIP_RAND */
|
||||
|
||||
/* Apply timer value if no report has been scheduled already. */
|
||||
|
@ -455,24 +455,25 @@ nd6_input(struct pbuf *p, struct netif *inp)
|
||||
|
||||
if (prefix_opt->flags & ND6_PREFIX_FLAG_ON_LINK) {
|
||||
/* Add to on-link prefix list. */
|
||||
s8_t prefix;
|
||||
|
||||
/* Get a memory-aligned copy of the prefix. */
|
||||
ip6_addr_set(ip6_current_dest_addr(), &(prefix_opt->prefix));
|
||||
|
||||
/* find cache entry for this prefix. */
|
||||
i = nd6_get_onlink_prefix(ip6_current_dest_addr(), inp);
|
||||
if (i < 0) {
|
||||
prefix = nd6_get_onlink_prefix(ip6_current_dest_addr(), inp);
|
||||
if (prefix < 0) {
|
||||
/* Create a new cache entry. */
|
||||
i = nd6_new_onlink_prefix(ip6_current_dest_addr(), inp);
|
||||
prefix = nd6_new_onlink_prefix(ip6_current_dest_addr(), inp);
|
||||
}
|
||||
if (i >= 0) {
|
||||
prefix_list[i].invalidation_timer = prefix_opt->valid_lifetime;
|
||||
if (prefix >= 0) {
|
||||
prefix_list[prefix].invalidation_timer = prefix_opt->valid_lifetime;
|
||||
|
||||
#if LWIP_IPV6_AUTOCONFIG
|
||||
if (prefix_opt->flags & ND6_PREFIX_FLAG_AUTONOMOUS) {
|
||||
/* Mark prefix as autonomous, so that address autoconfiguration can take place.
|
||||
* Only OR flag, so that we don't over-write other flags (such as ADDRESS_DUPLICATE)*/
|
||||
prefix_list[i].flags |= ND6_PREFIX_AUTOCONFIG_AUTONOMOUS;
|
||||
prefix_list[prefix].flags |= ND6_PREFIX_AUTOCONFIG_AUTONOMOUS;
|
||||
}
|
||||
#endif /* LWIP_IPV6_AUTOCONFIG */
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user