PERFORCE change 143897 for review

Peter Wemm peter at FreeBSD.org
Sat Jun 21 20:36:37 UTC 2008


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

Change 143897 by peter at peter_overcee on 2008/06/21 20:36:01

	IFC @143896

Affected files ...

.. //depot/projects/hammer/contrib/binutils/bfd/coff-mips.c#3 branch
.. //depot/projects/hammer/contrib/binutils/bfd/cpu-mips.c#3 branch
.. //depot/projects/hammer/contrib/binutils/bfd/elf32-mips.c#3 branch
.. //depot/projects/hammer/contrib/binutils/bfd/elf64-mips.c#3 branch
.. //depot/projects/hammer/contrib/binutils/bfd/mipsbsd.c#3 branch
.. //depot/projects/hammer/contrib/binutils/bfd/pe-mips.c#3 branch
.. //depot/projects/hammer/contrib/binutils/include/opcode/mips.h#3 branch
.. //depot/projects/hammer/contrib/gdtoa/gethex.c#5 integrate
.. //depot/projects/hammer/crypto/heimdal/acinclude.m4#3 branch
.. //depot/projects/hammer/lib/libarchive/archive.h#13 branch
.. //depot/projects/hammer/lib/libarchive/archive_read_support_format_mtree.c#6 integrate
.. //depot/projects/hammer/lib/libarchive/archive_write_disk.c#14 integrate
.. //depot/projects/hammer/lib/libarchive/test/test_read_format_isorr_bz2.c#4 integrate
.. //depot/projects/hammer/lib/libarchive/test/test_read_format_isorr_bz2.iso.bz2.uu#1 branch
.. //depot/projects/hammer/sys/amd64/amd64/pmap.c#181 integrate
.. //depot/projects/hammer/sys/netinet/libalias/alias.c#9 integrate
.. //depot/projects/hammer/tools/regression/lib/libc/stdio/test-scanfloat.c#8 integrate

Differences ...

==== //depot/projects/hammer/contrib/gdtoa/gethex.c#5 (text+ko) ====

@@ -113,8 +113,11 @@
 		e += e1;
 	  }
 	*sp = (char*)s;
-	if (zret)
-		return havedig ? STRTOG_Zero : STRTOG_NoNumber;
+	if (zret) {
+		if (!havedig)
+			*sp = s0 - 1;
+		return STRTOG_Zero;
+		}
 	n = s1 - s0 - 1;
 	for(k = 0; n > 7; n >>= 1)
 		k++;

==== //depot/projects/hammer/lib/libarchive/archive_read_support_format_mtree.c#6 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_mtree.c,v 1.8 2008/06/15 10:43:59 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_mtree.c,v 1.9 2008/06/21 19:06:37 kientzle Exp $");
 
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
@@ -1020,7 +1020,7 @@
 }
 
 /*
- * Since parsing octal escapes always makes strings shorter,
+ * Since parsing backslash sequences always makes strings shorter,
  * we can always do this conversion in-place.
  */
 static void
@@ -1041,13 +1041,57 @@
 		if (c == '/' && mentry != NULL)
 			mentry->full = 1;
 		if (c == '\\') {
-			if (src[0] >= '0' && src[0] <= '3'
-			    && src[1] >= '0' && src[1] <= '7'
-			    && src[2] >= '0' && src[2] <= '7') {
-				c = (src[0] - '0') << 6;
-				c |= (src[1] - '0') << 3;
-				c |= (src[2] - '0');
-				src += 3;
+			switch (src[0]) {
+			case '0':
+				if (src[1] < '0' || src[1] > '7') {
+					c = 0;
+					++src;
+					break;
+				}
+				/* FALLTHROUGH */
+			case '1':
+			case '2':
+			case '3':
+				if (src[1] >= '0' && src[1] <= '7' &&
+				    src[2] >= '0' && src[2] <= '7') {
+					c = (src[0] - '0') << 6;
+					c |= (src[1] - '0') << 3;
+					c |= (src[2] - '0');
+					src += 3;
+				}
+				break;
+			case 'a':
+				c = '\a';
+				++src;
+				break;
+			case 'b':
+				c = '\b';
+				++src;
+				break;
+			case 'f':
+				c = '\f';
+				++src;
+				break;
+			case 'n':
+				c = '\n';
+				++src;
+				break;
+			case 'r':
+				c = '\r';
+				++src;
+				break;
+			case 's':
+				c = ' ';
+				++src;
+				break;
+			case 't':
+				c = '\t';
+				++src;
+				break;
+			case 'v':
+				c = '\v';
+				++src;
+				break;
 			}
 		}
 		*dest++ = c;
@@ -1190,6 +1234,7 @@
 	const void *t;
 	const char *s;
 	void *p;
+	char *u;
 
 	/* Accumulate line in a line buffer. */
 	for (;;) {
@@ -1222,10 +1267,32 @@
 		total_size += bytes_read;
 		/* Null terminate. */
 		mtree->line.s[total_size] = '\0';
-		/* If we found '\n', clean up and return. */
-		if (p != NULL) {
-			*start = mtree->line.s;
-			return (total_size);
+		/* If we found an unescaped '\n', clean up and return. */
+		if (p == NULL)
+			continue;
+		for (u = mtree->line.s; *u; ++u) {
+			if (u[0] == '\n') {
+				*start = mtree->line.s;
+				return total_size;
+			}
+			if (u[0] == '#') {
+				if (p == NULL)
+					break;
+				*start = mtree->line.s;
+				return total_size;
+			}
+			if (u[0] != '\\')
+				continue;
+			if (u[1] == '\\') {
+				++u;
+				continue;
+			}
+			if (u[1] == '\n') {
+				memmove(u, u + 1,
+				    total_size - (u - mtree->line.s) + 1);
+				--total_size;
+				continue;    
+			}
 		}
 	}
 }

==== //depot/projects/hammer/lib/libarchive/archive_write_disk.c#14 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_disk.c,v 1.25 2008/05/26 17:00:23 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_disk.c,v 1.26 2008/06/21 19:05:29 kientzle Exp $");
 
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
@@ -1351,7 +1351,7 @@
 	if (*src == '\0') {
 		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
 		    "Invalid empty pathname");
-		return (ARCHIVE_WARN);
+		return (ARCHIVE_FAILED);
 	}
 
 	/* Skip leading '/'. */
@@ -1382,7 +1382,7 @@
 						archive_set_error(&a->archive,
 						    ARCHIVE_ERRNO_MISC,
 						    "Path contains '..'");
-						return (ARCHIVE_WARN);
+						return (ARCHIVE_FAILED);
 					}
 					lastdotdot = 1;
 				} else
@@ -1421,7 +1421,7 @@
 		archive_set_error(&a->archive,
 		    ARCHIVE_ERRNO_MISC,
 		    "Path contains trailing '..'");
-		return (ARCHIVE_WARN);
+		return (ARCHIVE_FAILED);
 	}
 	if (dest == a->name) {
 		/*

==== //depot/projects/hammer/lib/libarchive/test/test_read_format_isorr_bz2.c#4 (text+ko) ====

@@ -23,11 +23,11 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_isorr_bz2.c,v 1.3 2008/01/01 22:28:04 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_isorr_bz2.c,v 1.4 2008/06/21 19:11:51 kientzle Exp $");
 
 /*
 Execute the following to rebuild the data for this program:
-   tail -n +5 test-read_format-isorr_bz2.c | /bin/sh
+   tail -n +32 test_read_format_isorr_bz2.c | /bin/sh
 
 rm -rf /tmp/iso
 mkdir /tmp/iso
@@ -35,79 +35,37 @@
 echo "hello" >/tmp/iso/file
 ln /tmp/iso/file /tmp/iso/hardlink
 (cd /tmp/iso; ln -s file symlink)
-TZ=utc touch -afhm -t 197001010000.01 /tmp/iso /tmp/iso/file /tmp/iso/dir
-TZ=utc touch -afhm -t 196912312359.58 /tmp/iso/symlink
-mkhybrid -R -uid 1 -gid 2 /tmp/iso | bzip2 > data.iso.bz2
-cat data.iso.bz2 | ./maketest.pl > data.c
+TZ=utc touch -afhm -t 197001020000.01 /tmp/iso /tmp/iso/file /tmp/iso/dir
+TZ=utc touch -afhm -t 197001030000.02 /tmp/iso/symlink
+mkhybrid -R -uid 1 -gid 2 /tmp/iso | bzip2 > test_read_format_isorr_bz2.iso.bz2
+F=test_read_format_isorr_bz2.iso.bz2
+uuencode $F $F > $F.uu
 exit 1
  */
 
-static unsigned char archive[] = {
-'B','Z','h','9','1','A','Y','&','S','Y','G',11,4,'c',0,0,199,255,221,255,
-255,203,252,221,'c',251,248,'?',255,223,224,167,255,222,'&','!',234,'$',0,
-'0',1,' ',0,'D',2,129,8,192,3,14,'2','3','$',19,184,'J',' ','F',168,244,201,
-149,'6','Q',226,155,'S',212,209,160,'h','4','i',160,26,13,0,244,134,212,0,
-218,'O',212,153,1,144,244,128,148,' ',147,13,' ',213,'=','1','\'',169,166,
-128,'=','!',233,0,208,0,26,0,0,30,160,'h',0,'4','z',130,180,163,'@',0,0,4,
-211,0,0,0,2,'b','`',0,0,0,0,0,8,146,133,'F',154,'y','A',163,'A',161,163,'@',
-'z',134,'C','C','F',131,'F','@',0,0,0,0,6,154,26,'Q',24,234,180,'P',172,251,
-'=',2,'P','H','&','Y','o',130,28,'"',229,210,247,227,248,200,'?','6',161,
-'?',170,'H',172,'"','H','I',16,'2','"','&',148,'G',133,'T','z',224,1,215,
-' ',0,191,184,10,160,24,248,180,183,244,156,'K',202,133,208,'U',5,'6','C',
-26,144,'H',168,'H','H','(','"',151,'@','m',223,'(','P',169,'e',145,148,'6',
-237,235,7,227,204,']','k','{',241,187,227,244,251,':','a','L',138,'#','R',
-'"',221,'_',239,')',140,'*','*',172,'Q',16,1,16,207,166,251,233,'Z',169,'4',
-'_',195,'a',14,18,231,'}',14,139,137,'e',213,185,'T',194,'D','`',25,'$',187,
-208,'%','c',162,'~',181,'@',204,'2',238,'P',161,213,127,'I',169,3,' ','o',
-6,161,16,128,'F',214,'S','m',6,244,11,229,'Z','y','.',176,'q',' ',248,167,
-204,26,193,'q',211,241,214,133,221,212,'I','`',28,244,'N','N','f','H','9',
-'w',245,209,'*',20,26,208,'h','(',194,156,192,'l',';',192,'X','T',151,177,
-209,'0',156,16,'=',20,'k',184,144,'z',26,'j',133,194,'9',227,'<','[','^',
-17,'w','p',225,220,248,'>',205,'>','[',19,'5',155,17,175,28,28,168,175,'n',
-'\'','c','w',27,222,204,'k','n','x','I',23,237,'c',145,11,184,'A','(',1,169,
-'0',180,189,134,'\\','Y','x',187,'C',151,'d','k','y','-','L',218,138,'s',
-'*','(',12,'h',242,'*',17,'E','L',202,146,138,'l','0',217,160,'9','.','S',
-214,198,143,'3','&',237,'=','t','P',168,214,210,'`','p','J',181,'H',138,149,
-'1','B',206,22,164,'[','O','A',172,134,224,179,219,166,184,'X',185,'W',154,
-219,19,161,'Y',184,220,237,147,'9',191,237,'&','i','_',226,146,205,160,'@',
-'b',182,';',3,'!',183,'J','t',161,160,178,173,'S',235,':','2',159,':',245,
-'{','U',174,'P',142,'G','(',')',9,168,185,'A','U',231,193,'g',213,'e',12,
-'X',223,22,249,')',152,237,'G',150,156,3,201,245,212,'2',218,209,177,196,
-235,'_','~',137,24,31,196,232,'B',172,'w',159,24,'n',156,150,225,'1','y',
-22,'#',138,193,227,232,169,170,166,179,1,11,182,'i',')',160,180,198,175,128,
-249,167,5,194,142,183,'f',134,206,180,'&','E','!','[',31,195,':',192,'s',
-232,187,'N',131,'Y',137,243,15,'y',12,'J',163,'-',242,'5',197,151,130,163,
-240,220,'T',161,'L',159,141,159,152,'4',18,128,'.','^',250,168,200,163,'P',
-231,'Y','w','F','U',186,'x',190,16,'0',228,22,'9','F','t',168,157,'i',190,
-'+',246,141,142,18,' ','M',174,197,'O',165,'m',224,27,'b',150,'|','W','H',
-196,'.','*','Q','$',225,'I','-',148,169,'F',7,197,'m','-',130,153,0,158,21,
-'(',221,221,226,206,'g',13,159,163,'y',176,'~',158,'k','4','q','d','s',177,
-'7',14,217,'1',173,206,228,'t',250,200,170,162,'d','2','Z','$','e',168,224,
-223,129,174,229,165,187,252,203,'-',28,'`',207,183,'-','/',127,196,230,131,
-'B',30,237,' ',8,26,194,'O',132,'L','K','\\',144,'L','c',1,10,176,192,'c',
-0,244,2,168,3,0,'+',233,186,16,17,'P',17,129,252,'2',0,2,154,247,255,166,
-'.',228,138,'p',161,' ',142,22,8,198};
-
 DEFINE_TEST(test_read_format_isorr_bz2)
 {
+	const char *refname = "test_read_format_isorr_bz2.iso.bz2";
 	struct archive_entry *ae;
 	struct archive *a;
 	const void *p;
 	size_t size;
 	off_t offset;
+
+	extract_reference_file(refname);
 	assert((a = archive_read_new()) != NULL);
-	assert(0 == archive_read_support_compression_all(a));
-	assert(0 == archive_read_support_format_all(a));
-	assert(0 == archive_read_open_memory(a, archive, sizeof(archive)));
+	assertEqualInt(0, archive_read_support_compression_all(a));
+	assertEqualInt(0, archive_read_support_format_all(a));
+	assertEqualInt(0, archive_read_open_filename(a, refname, 10240));
 
 	/* First entry is '.' root directory. */
-	assert(0 == archive_read_next_header(a, &ae));
+	assertEqualInt(0, archive_read_next_header(a, &ae));
 	assertEqualString(".", archive_entry_pathname(ae));
 	assert(S_ISDIR(archive_entry_stat(ae)->st_mode));
 	assertEqualInt(2048, archive_entry_size(ae));
-	assertEqualInt(1, archive_entry_mtime(ae));
+	assertEqualInt(86401, archive_entry_mtime(ae));
 	assertEqualInt(0, archive_entry_mtime_nsec(ae));
-	assertEqualInt(1, archive_entry_ctime(ae));
+	assertEqualInt(86401, archive_entry_ctime(ae));
 	assertEqualInt(0, archive_entry_stat(ae)->st_nlink);
 	assertEqualInt(0, archive_entry_uid(ae));
 	assertEqualIntA(a, ARCHIVE_EOF,
@@ -115,66 +73,66 @@
 	assertEqualInt(size, 0);
 
 	/* A directory. */
-	assert(0 == archive_read_next_header(a, &ae));
+	assertEqualInt(0, archive_read_next_header(a, &ae));
 	assertEqualString("dir", archive_entry_pathname(ae));
 	assert(S_ISDIR(archive_entry_stat(ae)->st_mode));
-	assert(2048 == archive_entry_size(ae));
-	assert(1 == archive_entry_mtime(ae));
-	assert(1 == archive_entry_atime(ae));
-	assert(2 == archive_entry_stat(ae)->st_nlink);
-	assert(1 == archive_entry_uid(ae));
-	assert(2 == archive_entry_gid(ae));
+	assertEqualInt(2048, archive_entry_size(ae));
+	assertEqualInt(86401, archive_entry_mtime(ae));
+	assertEqualInt(86401, archive_entry_atime(ae));
+	assertEqualInt(2, archive_entry_stat(ae)->st_nlink);
+	assertEqualInt(1, archive_entry_uid(ae));
+	assertEqualInt(2, archive_entry_gid(ae));
 
 	/* A regular file. */
-	assert(0 == archive_read_next_header(a, &ae));
+	assertEqualInt(0, archive_read_next_header(a, &ae));
 	assertEqualString("file", archive_entry_pathname(ae));
 	assert(S_ISREG(archive_entry_stat(ae)->st_mode));
-	assert(6 == archive_entry_size(ae));
-	assert(0 == archive_read_data_block(a, &p, &size, &offset));
-	assert(6 == size);
-	assert(0 == offset);
-	assert(0 == memcmp(p, "hello\n", 6));
-	assert(1 == archive_entry_mtime(ae));
-	assert(1 == archive_entry_atime(ae));
-	assert(2 == archive_entry_stat(ae)->st_nlink);
-	assert(1 == archive_entry_uid(ae));
-	assert(2 == archive_entry_gid(ae));
+	assertEqualInt(6, archive_entry_size(ae));
+	assertEqualInt(0, archive_read_data_block(a, &p, &size, &offset));
+	assertEqualInt(6, size);
+	assertEqualInt(0, offset);
+	assertEqualInt(0, memcmp(p, "hello\n", 6));
+	assertEqualInt(86401, archive_entry_mtime(ae));
+	assertEqualInt(86401, archive_entry_atime(ae));
+	assertEqualInt(2, archive_entry_stat(ae)->st_nlink);
+	assertEqualInt(1, archive_entry_uid(ae));
+	assertEqualInt(2, archive_entry_gid(ae));
 
 	/* A hardlink to the regular file. */
-	assert(0 == archive_read_next_header(a, &ae));
+	assertEqualInt(0, archive_read_next_header(a, &ae));
 	assertEqualString("hardlink", archive_entry_pathname(ae));
 	assert(S_ISREG(archive_entry_stat(ae)->st_mode));
 	assertEqualString("file", archive_entry_hardlink(ae));
-	assert(6 == archive_entry_size(ae));
-	assert(1 == archive_entry_mtime(ae));
-	assert(1 == archive_entry_atime(ae));
-	assert(2 == archive_entry_stat(ae)->st_nlink);
-	assert(1 == archive_entry_uid(ae));
-	assert(2 == archive_entry_gid(ae));
+	assertEqualInt(6, archive_entry_size(ae));
+	assertEqualInt(86401, archive_entry_mtime(ae));
+	assertEqualInt(86401, archive_entry_atime(ae));
+	assertEqualInt(2, archive_entry_stat(ae)->st_nlink);
+	assertEqualInt(1, archive_entry_uid(ae));
+	assertEqualInt(2, archive_entry_gid(ae));
 
 	/* A symlink to the regular file. */
-	assert(0 == archive_read_next_header(a, &ae));
+	assertEqualInt(0, archive_read_next_header(a, &ae));
 	assertEqualString("symlink", archive_entry_pathname(ae));
 	assert(S_ISLNK(archive_entry_stat(ae)->st_mode));
 	assertEqualString("file", archive_entry_symlink(ae));
-	assert(0 == archive_entry_size(ae));
-	assert(-2 == archive_entry_mtime(ae));
-	assert(-2 == archive_entry_atime(ae));
-	assert(1 == archive_entry_stat(ae)->st_nlink);
-	assert(1 == archive_entry_uid(ae));
-	assert(2 == archive_entry_gid(ae));
+	assertEqualInt(0, archive_entry_size(ae));
+	assertEqualInt(172802, archive_entry_mtime(ae));
+	assertEqualInt(172802, archive_entry_atime(ae));
+	assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
+	assertEqualInt(1, archive_entry_uid(ae));
+	assertEqualInt(2, archive_entry_gid(ae));
 
 	/* End of archive. */
-	assert(ARCHIVE_EOF == archive_read_next_header(a, &ae));
+	assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae));
 
 	/* Verify archive format. */
-	assert(archive_compression(a) == ARCHIVE_COMPRESSION_BZIP2);
-	assert(archive_format(a) == ARCHIVE_FORMAT_ISO9660_ROCKRIDGE);
+	assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_BZIP2);
+	assertEqualInt(archive_format(a), ARCHIVE_FORMAT_ISO9660_ROCKRIDGE);
 
 	/* Close the archive. */
-	assert(0 == archive_read_close(a));
+	assertEqualInt(0, archive_read_close(a));
 #if ARCHIVE_API_VERSION > 1
-	assert(0 == archive_read_finish(a));
+	assertEqualInt(0, archive_read_finish(a));
 #else
 	archive_read_finish(a);
 #endif

==== //depot/projects/hammer/sys/amd64/amd64/pmap.c#181 (text+ko) ====

@@ -77,7 +77,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/amd64/pmap.c,v 1.622 2008/06/20 05:22:09 alc Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/amd64/pmap.c,v 1.623 2008/06/21 19:19:09 alc Exp $");
 
 /*
  *	Manages physical address maps.
@@ -448,8 +448,10 @@
 	/* Read-only from zero to physfree */
 	/* XXX not fully used, underneath 2M pages */
 	for (i = 0; (i << PAGE_SHIFT) < *firstaddr; i++) {
-		((pt_entry_t *)KPTphys)[i] = i << PAGE_SHIFT;
-		((pt_entry_t *)KPTphys)[i] |= PG_RW | PG_V | PG_G;
+		((pt_entry_t *)KPTphys)[(KERNBASE - VM_MIN_KERNEL_ADDRESS) /
+		    PAGE_SIZE + i] = i << PAGE_SHIFT;
+		((pt_entry_t *)KPTphys)[(KERNBASE - VM_MIN_KERNEL_ADDRESS) /
+		    PAGE_SIZE + i] |= PG_RW | PG_V | PG_G;
 	}
 
 	/* Now map the page tables at their location within PTmap */
@@ -461,8 +463,10 @@
 	/* Map from zero to end of allocations under 2M pages */
 	/* This replaces some of the KPTphys entries above */
 	for (i = 0; (i << PDRSHIFT) < *firstaddr; i++) {
-		((pd_entry_t *)KPDphys)[i] = i << PDRSHIFT;
-		((pd_entry_t *)KPDphys)[i] |= PG_RW | PG_V | PG_PS | PG_G;
+		((pd_entry_t *)KPDphys)[(KERNBASE - VM_MIN_KERNEL_ADDRESS) /
+		    NBPDR + i] = i << PDRSHIFT;
+		((pd_entry_t *)KPDphys)[(KERNBASE - VM_MIN_KERNEL_ADDRESS) /
+		    NBPDR + i] |= PG_RW | PG_V | PG_PS | PG_G;
 	}
 
 	/* And connect up the PD to the PDP */

==== //depot/projects/hammer/sys/netinet/libalias/alias.c#9 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/netinet/libalias/alias.c,v 1.63 2008/06/01 17:52:40 mav Exp $");
+__FBSDID("$FreeBSD: src/sys/netinet/libalias/alias.c,v 1.64 2008/06/21 20:18:57 mav Exp $");
 
 /*
     Alias.c provides supervisory control for the functions of the
@@ -271,7 +271,7 @@
 		    int create);
 
 static int	UdpAliasIn(struct libalias *, struct ip *);
-static int	UdpAliasOut(struct libalias *, struct ip *, int create);
+static int	UdpAliasOut(struct libalias *, struct ip *, int, int create);
 
 static int	TcpAliasIn(struct libalias *, struct ip *);
 static int	TcpAliasOut(struct libalias *, struct ip *, int, int create);
@@ -717,19 +717,18 @@
 	struct alias_link *lnk;
 
 	LIBALIAS_LOCK_ASSERT(la);
-/* Return if proxy-only mode is enabled */
-	if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
-		return (PKT_ALIAS_OK);
 
 	ud = (struct udphdr *)ip_next(pip);
 
 	lnk = FindUdpTcpIn(la, pip->ip_src, pip->ip_dst,
 	    ud->uh_sport, ud->uh_dport,
-	    IPPROTO_UDP, 1);
+	    IPPROTO_UDP, !(la->packetAliasMode & PKT_ALIAS_PROXY_ONLY));
 	if (lnk != NULL) {
 		struct in_addr alias_address;
 		struct in_addr original_address;
+		struct in_addr proxy_address;
 		u_short alias_port;
+		u_short proxy_port;
 		int accumulate;
 		int r = 0, error;
 		struct alias_data ad = {
@@ -744,8 +743,10 @@
 
 		alias_address = GetAliasAddress(lnk);
 		original_address = GetOriginalAddress(lnk);
+		proxy_address = GetProxyAddress(lnk);
 		alias_port = ud->uh_dport;
 		ud->uh_dport = GetOriginalPort(lnk);
+		proxy_port = GetProxyPort(lnk);
 
 		/* Walk out chain. */		
 		error = find_handler(IN, UDP, la, pip, &ad);
@@ -757,8 +758,32 @@
 			accumulate -= ud->uh_dport;
 			accumulate += twowords(&alias_address);
 			accumulate -= twowords(&original_address);
+
+/* If this is a proxy packet, modify checksum because of source change.*/
+        		if (proxy_port != 0) {
+		                accumulate += ud->uh_sport;
+		                accumulate -= proxy_port;
+	                }
+
+	                if (proxy_address.s_addr != 0) {
+				accumulate += twowords(&pip->ip_src);
+				accumulate -= twowords(&proxy_address);
+	                }
+
 			ADJUST_CHECKSUM(accumulate, ud->uh_sum);
 		}
+/* XXX: Could the two if's below be concatenated to one ? */
+/* Restore source port and/or address in case of proxying*/
+
+    		if (proxy_port != 0)
+        		ud->uh_sport = proxy_port;
+
+    		if (proxy_address.s_addr != 0) {
+        		DifferentialChecksum(&pip->ip_sum,
+                	    &proxy_address, &pip->ip_src, 2);
+	        	pip->ip_src = proxy_address;
+    		}
+
 /* Restore original IP address */
 		DifferentialChecksum(&pip->ip_sum,
 		    &original_address, &pip->ip_dst, 2);
@@ -776,19 +801,50 @@
 }
 
 static int
-UdpAliasOut(struct libalias *la, struct ip *pip, int create)
+UdpAliasOut(struct libalias *la, struct ip *pip, int maxpacketsize, int create)
 {
 	struct udphdr *ud;
 	struct alias_link *lnk;
+	struct in_addr dest_address;
+	struct in_addr proxy_server_address;
+	u_short dest_port;
+	u_short proxy_server_port;
+	int proxy_type;
 	int error;
 
 	LIBALIAS_LOCK_ASSERT(la);
-/* Return if proxy-only mode is enabled */
-	if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
+
+/* Return if proxy-only mode is enabled and not proxyrule found.*/
+	ud = (struct udphdr *)ip_next(pip);
+	proxy_type = ProxyCheck(la, &proxy_server_address, 
+		&proxy_server_port, pip->ip_src, pip->ip_dst, 
+		ud->uh_dport, pip->ip_p);
+	if (proxy_type == 0 && (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY))
 		return (PKT_ALIAS_OK);
 
-	ud = (struct udphdr *)ip_next(pip);
+/* If this is a transparent proxy, save original destination,
+ * then alter the destination and adjust checksums */
+	dest_port = ud->uh_dport;
+	dest_address = pip->ip_dst;
+
+	if (proxy_type != 0) {
+	        int accumulate;
+
+		accumulate = twowords(&pip->ip_dst);
+		accumulate -= twowords(&proxy_server_address);
+
+	        ADJUST_CHECKSUM(accumulate, pip->ip_sum);
 
+		if (ud->uh_sum != 0) {
+			accumulate = twowords(&pip->ip_dst);
+			accumulate -= twowords(&proxy_server_address);
+    			accumulate += ud->uh_dport;
+	        	accumulate -= proxy_server_port;
+	    		ADJUST_CHECKSUM(accumulate, ud->uh_sum);
+		}
+	        pip->ip_dst = proxy_server_address;
+	        ud->uh_dport = proxy_server_port;
+	}
 	lnk = FindUdpTcpOut(la, pip->ip_src, pip->ip_dst,
 	    ud->uh_sport, ud->uh_dport,
 	    IPPROTO_UDP, create);
@@ -805,6 +861,16 @@
 			.maxpktsize = 0
 		};
 
+/* Save original destination address, if this is a proxy packet.
+ * Also modify packet to include destination encoding.  This may
+ * change the size of IP header. */
+		if (proxy_type != 0) {
+	                SetProxyPort(lnk, dest_port);
+	                SetProxyAddress(lnk, dest_address);
+	                ProxyModify(la, lnk, pip, maxpacketsize, proxy_type);
+	                ud = (struct udphdr *)ip_next(pip);
+	        }
+
 		alias_address = GetAliasAddress(lnk);
 		alias_port = GetAliasPort(lnk);
 
@@ -1409,7 +1475,7 @@
 			iresult = IcmpAliasOut(la, pip, create);
 			break;
 		case IPPROTO_UDP:
-			iresult = UdpAliasOut(la, pip, create);
+			iresult = UdpAliasOut(la, pip, maxpacketsize, create);
 			break;
 			case IPPROTO_TCP:
 			iresult = TcpAliasOut(la, pip, maxpacketsize, create);

==== //depot/projects/hammer/tools/regression/lib/libc/stdio/test-scanfloat.c#8 (text+ko) ====

@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/tools/regression/lib/libc/stdio/test-scanfloat.c,v 1.9 2007/12/09 21:00:12 das Exp $");
+__FBSDID("$FreeBSD: src/tools/regression/lib/libc/stdio/test-scanfloat.c,v 1.10 2008/06/21 19:28:26 das Exp $");
 
 #include <assert.h>
 #include <fenv.h>
@@ -49,8 +49,9 @@
 	long double ld = 0.0;
 	double d = 0.0;
 	float f = 0.0;
+	char *endp;
 
-	printf("1..3\n");
+	printf("1..4\n");
 
 	buf[0] = '\0';
 	assert(setlocale(LC_NUMERIC, ""));
@@ -274,6 +275,15 @@
 
 	printf("ok 3 - scanfloat\n");
 
+	/*
+	 * Tests specific to strtod().
+	 */
+
+	assert(strtod("0xy", &endp) == 0);
+	assert(strcmp("xy", endp) == 0);
+
+	printf("ok 4 - scanfloat\n");
+
 	return (0);
 }
 


More information about the p4-projects mailing list