Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Aug 2007 10:03:14 GMT
From:      Fredrik Lindberg <fli@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 124999 for review
Message-ID:  <200708101003.l7AA3END098258@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=124999

Change 124999 by fli@fli_nexus on 2007/08/10 10:02:55

	Do not assume that the name passed to name_compress() is properly
	dot-terminated (even though it should be).

Affected files ...

.. //depot/projects/soc2007/fli-mdns_sd/mdnsd/stack_packet.c#8 edit

Differences ...

==== //depot/projects/soc2007/fli-mdns_sd/mdnsd/stack_packet.c#8 (text+ko) ====

@@ -231,14 +231,15 @@
  */
 static int
 name_compress(struct hashtbl *ht, char *str, size_t slen, char *dst,
-	size_t *dlen, int pkg_offset)
+	    size_t *dlen, int pkg_offset)
+
 {
 	char *p, *q;
 	void *res;
 	int i;
 	uint16_t offset;
 
-	if (slen > *dlen)
+	if (slen >= *dlen)
 		return (-1);
 
 	p = str + slen - 1;
@@ -247,7 +248,14 @@
 	/*
 	 * Turn into a normal DNS label without compression.
 	 */
-	while (p != str) {
+	if (*p == '.')
+		p--;
+	else {
+		q++;
+		slen++;
+	}
+	*q-- = 0;
+	while (p != str && q != (dst + 1) ) {
 		if (*p == '.') {
 			*q = (char)i;
 			i = 0;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200708101003.l7AA3END098258>