1
0
Fork 0
forked from nuttx/nuttx-update

Merged in masayuki2009/nuttx.nuttx/network_test (pull request #617)

Fix some bugs in networking

* netdb: Fix boundary conditions in dns_recv_response()

    Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>

* Fix typos in include/nuttx/net/dns.h

    Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>

Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
Masayuki Ishikawa 2018-03-27 01:31:06 +00:00 committed by Gregory Nutt
parent 759e510c28
commit d393f43caa
2 changed files with 4 additions and 4 deletions

View file

@ -56,14 +56,14 @@
/* DNS classes */
#define DNS_CLASS_IN 1 /* RFC 1035 Internet */
#define DNS_CLASS CH 3 /* N/A Chaos */
#define DNS_CLASS_CH 3 /* N/A Chaos */
#define DNS_CLASS_HS 4 /* N/A Hesiod */
#define DNS_CLASS_QNONE 254 /* RFC 2136 QCLASS NONE */
#define DNS_CLASS_QANY 255 /* RFC 1035 QCLASS ANY */
/* DNS resource record types */
#define DNS_RECTYPE_A 1 /* RFC 1035 IPv4 ddress record */
#define DNS_RECTYPE_A 1 /* RFC 1035 IPv4 address record */
#define DNS_RECTYPE_AAAA 28 /* RFC 3596 IPv6 address record */
#define DNS_RECTYPE_AFSDB 18 /* RFC 1183 AFS database record */
#define DNS_RECTYPE_APL 42 /* RFC 3123 Address Prefix List */

View file

@ -393,7 +393,7 @@ static int dns_recv_response(int sd, FAR struct sockaddr *addr,
if (ans->type == HTONS(DNS_RECTYPE_A) &&
ans->class == HTONS(DNS_CLASS_IN) &&
ans->len == HTONS(4) &&
nameptr + 10 + 4 < endofbuffer)
nameptr + 10 + 4 <= endofbuffer)
{
ans->u.ipv4.s_addr = *(FAR uint32_t *)(nameptr + 10);
@ -426,7 +426,7 @@ static int dns_recv_response(int sd, FAR struct sockaddr *addr,
if (ans->type == HTONS(DNS_RECTYPE_AAAA) &&
ans->class == HTONS(DNS_CLASS_IN) &&
ans->len == HTONS(16) &&
nameptr + 10 + 16 < endofbuffer)
nameptr + 10 + 16 <= endofbuffer)
{
memcpy(&ans->u.ipv6.s6_addr, nameptr + 10, 16);