PERFORCE change 124999 for review

Fredrik Lindberg fli at FreeBSD.org
Fri Aug 10 03:03:16 PDT 2007


http://perforce.freebsd.org/chv.cgi?CH=124999

Change 124999 by fli at 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;


More information about the p4-projects mailing list