Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F144003721
D21266.id60871.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D21266.id60871.diff
View Options
Index: sbin/ping6/ping6.c
===================================================================
--- sbin/ping6/ping6.c
+++ sbin/ping6/ping6.c
@@ -279,7 +279,7 @@
static void pr_nodeaddr(struct icmp6_nodeinfo *, int);
static int myechoreply(const struct icmp6_hdr *);
static int mynireply(const struct icmp6_nodeinfo *);
-static char *dnsdecode(const u_char *, const u_char *, const u_char *,
+static const char *dnsdecode(const u_char *, const u_char *, const u_char *,
char *, size_t);
static void pr_pack(u_char *, int, struct msghdr *);
static void pr_exthdrs(struct msghdr *);
@@ -1428,10 +1428,26 @@
return 0;
}
-static char *
+/*
+ * Decode a name from a DNS message.
+ *
+ * Format of the message is described in RFC 1035 subsection 4.1.4.
+ *
+ * Arguments:
+ * sp - Pointer to a DNS pointer octet or to the first octet of a label
+ * in the message.
+ * ep - Pointer to the end of the message (one step past the last octet).
+ * base - Pointer to the beginning of the message.
+ * buf - Buffer into which the decoded name will be saved.
+ * bufsiz - Size of the buffer 'buf'.
+ *
+ * Return value:
+ * Pointer to an octet immediately following the ending zero octet
+ * of the decoded label, or NULL if an error occured.
+ */
+static const char *
dnsdecode(const u_char *sp, const u_char *ep, const u_char *base, char *buf,
size_t bufsiz)
- /*base for compressed name*/
{
int i;
const u_char *cp;
@@ -1484,8 +1500,7 @@
if (i != 0)
return NULL; /*not terminated*/
cp++;
- sp = cp;
- return buf;
+ return cp;
}
/*
@@ -1505,7 +1520,8 @@
int hoplim;
struct sockaddr *from;
int fromlen;
- u_char *cp = NULL, *dp, *end = buf + cc;
+ const u_char *cp = NULL;
+ u_char *dp, *end = buf + cc;
struct in6_pktinfo *pktinfo = NULL;
struct timespec tv, tp;
struct tv32 *tpp;
@@ -1677,9 +1693,10 @@
} else {
i = 0;
while (cp < end) {
- if (dnsdecode((const u_char *)cp, end,
+ cp = dnsdecode((const u_char *)cp, end,
(const u_char *)(ni + 1), dnsname,
- sizeof(dnsname)) == NULL) {
+ sizeof(dnsname));
+ if (cp == NULL) {
printf("???");
break;
}
@@ -2444,8 +2461,9 @@
}
printf(", subject=%s", niqcode[ni->ni_code]);
cp = (const u_char *)(ni + 1);
- if (dnsdecode(cp, end, NULL, dnsname,
- sizeof(dnsname)) != NULL)
+ cp = dnsdecode(cp, end, NULL, dnsname,
+ sizeof(dnsname));
+ if (cp != NULL)
printf("(%s)", dnsname);
else
printf("(invalid)");
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Feb 4, 5:43 AM (20 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28432122
Default Alt Text
D21266.id60871.diff (2 KB)
Attached To
Mode
D21266: ping6: Fix dnsdecode() bug introduced by r350859
Attached
Detach File
Event Timeline
Log In to Comment