Browse Source

Plan 9 from Bell Labs 2012-06-20

David du Colombier 11 years ago
parent
commit
eab6e40f99

+ 1 - 2
sys/src/9/omap/words

@@ -76,8 +76,7 @@ There are four USB errata that need to be looked into for the igepv2
 
 Flash
 
-access to nand flash would be handy for nvram and paqfs or sacfs file
-systems.
+access to nand flash would be handy for nvram and paqfs file systems.
 
 In the flash, x-loader occupies up to 0x20000, then u-boot from
 0x80000 to 0x1e0000, and there's a linux kernel after that (if you

+ 5 - 5
sys/src/cmd/seconds.c

@@ -103,12 +103,12 @@ tryabsdate(char **fields, int nf, Tm *now, Tm *tm)
 	int i, mer = HR24, bigval = -1;
 	long flg = 0, ty;
 	char *p;
-	char upzone[32];
 	Datetok *tp;
 
 	now = localtime(time(0));	/* default to local time (zone) */
 	tm->tzoff = now->tzoff;
-	strncpy(tm->zone, now->zone, sizeof tm->zone);
+	strncpy(tm->zone, now->zone, sizeof tm->zone - 1);
+	tm->zone[sizeof tm->zone - 1] = '\0';
 
 	tm->mday = tm->mon = tm->year = -1;	/* mandatory */
 	tm->hour = tm->min = tm->sec = 0;
@@ -145,11 +145,11 @@ tryabsdate(char **fields, int nf, Tm *now, Tm *tm)
 		case Tz:
 			tm->tzoff = FROMVAL(tp);
 			/* tm2sec needs the name in upper case */
-			strcpy(upzone, fields[i]);
-			for (p = upzone; *p; p++)
+			strncpy(tm->zone, fields[i], sizeof tm->zone - 1);
+			tm->zone[sizeof tm->zone - 1] = '\0';
+			for (p = tm->zone; *p; p++)
 				if (isascii(*p) && islower(*p))
 					*p = toupper(*p);
-			strncpy(tm->zone, upzone, sizeof tm->zone);
 			break;
 		case Ignore:
 			break;

+ 8 - 4
sys/src/cmd/ssh2/dial.c

@@ -46,7 +46,7 @@ struct Conn {
 
 	int	dfd;
 	int	cfd;
-	char	dir[NETPATHLEN];
+	char	dir[NETPATHLEN+1];
 	char	err[ERRMAX];
 };
 struct Dest {
@@ -185,7 +185,8 @@ notedeath(Dest *dp, char *exitsts)
 				closeopenfd(&conn->dfd);
 				closeopenfd(&conn->cfd);
 			}
-			strncpy(conn->err, fields[4], sizeof conn->err);
+			strncpy(conn->err, fields[4], sizeof conn->err - 1);
+			conn->err[sizeof conn->err - 1] = '\0';
 			conn->dead = 1;
 			return;
 		}
@@ -225,8 +226,10 @@ fillinds(DS *ds, Dest *dp)
 	conn = &dp->conn[dp->winner];
 	if (ds->cfdp)
 		*ds->cfdp = conn->cfd;
-	if (ds->dir)
+	if (ds->dir) {
 		strncpy(ds->dir, conn->dir, NETPATHLEN);
+		ds->dir[NETPATHLEN] = '\0';
+	}
 	return conn->dfd;
 }
 
@@ -250,7 +253,8 @@ connectwait(Dest *dp, char *besterr)
 	for (conn = dp->conn; conn < dp->connend; conn++)
 		if (conn - dp->conn != dp->winner && conn->dead &&
 		    conn->err[0]) {
-			strncpy(besterr, conn->err, ERRMAX);
+			strncpy(besterr, conn->err, ERRMAX-1);
+			conn->err[ERRMAX-1] = '\0';
 			break;
 		}
 	return dp->winner;

+ 11 - 5
sys/src/cmd/ssh2/dial.thread.c

@@ -47,7 +47,7 @@ struct DS {
 
 struct Conn {
 	int	cfd;
-	char	dir[NETPATHLEN];
+	char	dir[NETPATHLEN+1];
 };
 struct Dest {
 	DS	*ds;
@@ -257,16 +257,20 @@ recvresults(Dest *dp, int block)
 				dp->windfd = tup->dfd;
 				if (ds->cfdp)
 					*ds->cfdp = tup->cfd;
-				if (ds->dir)
+				if (ds->dir) {
 					strncpy(ds->dir, tup->conndir,
 						NETPATHLEN);
+					ds->dir[NETPATHLEN] = '\0';
+				}
 				intrcallprocs(dp);
 			} else {
 				close(tup->dfd);
 				close(tup->cfd);
 			}
-		else if (dp->err[0] == '\0' && tup->err)
-			strncpy(dp->err, tup->err, ERRMAX);
+		else if (dp->err[0] == '\0' && tup->err) {
+			strncpy(dp->err, tup->err, ERRMAX - 1);
+			dp->err[ERRMAX - 1] = '\0';
+		}
 		free(tup->conndir);
 		free(tup->err);
 		free(tup);
@@ -327,8 +331,10 @@ call1(char *clone, char *rem, Dest *dp, Conn *conn)
 
 	if (ds->cfdp)
 		*ds->cfdp = conn->cfd;
-	if (ds->dir)
+	if (ds->dir) {
 		strncpy(ds->dir, conn->dir, NETPATHLEN);
+		ds->dir[NETPATHLEN] = '\0';
+	}
 	return dfd;
 }
 

File diff suppressed because it is too large
+ 536 - 633
sys/src/cmd/ssh2/dup.out


File diff suppressed because it is too large
+ 367 - 348
sys/src/cmd/ssh2/dup.pro


+ 6 - 6
sys/src/cmd/ssh2/dup.sum

@@ -2,18 +2,18 @@
 Summary:
 Reporting parameterized matches of at least 3 lines.
 15 files
-7217 lines in original code,
-6256 lines after pruning white space and comments.
+7227 lines in original code,
+6266 lines after pruning white space and comments.
 
-2186 lines were involved in 614 matches
-These constitute 35 percent of the ncsl.
-Approximately 1385 lines are redundant,or 22 percent of the ncsl.
+2245 lines were involved in 615 matches
+These constitute 36 percent of the ncsl.
+Approximately 1411 lines are redundant,or 23 percent of the ncsl.
 
 match length: number of matches of that length
 	   3: 262
 	   4: 187
 	   5:  35
-	   6:  48
+	   6:  49
 	   7:  23
 	   8:  13
 	   9:  13

+ 12 - 12
sys/src/cmd/ssh2/dup.xpr

@@ -6,9 +6,9 @@ percent of file involved, #lines in file involved; file2,filename2
       26, 11; 0,cipher3des.c:
       26, 11; 0,cipher3des.c:
 
-36, 28, 5; 1,1
-      61, 48; 1,cipheraes.c:
-      61, 48; 1,cipheraes.c:
+40, 31, 5; 1,1
+      70, 55; 1,cipheraes.c:
+      70, 55; 1,cipheraes.c:
 
 7, 4, 1; 2,2
       13, 8; 2,cipherblowfish.c:
@@ -30,9 +30,9 @@ percent of file involved, #lines in file involved; file2,filename2
       8, 34; 7,dial.thread.c:
       8, 34; 7,dial.thread.c:
 
-22, 647, 316; 9,9
-      34, 996; 9,netssh.c:
-      34, 996; 9,netssh.c:
+22, 643, 316; 9,9
+      34, 998; 9,netssh.c:
+      34, 998; 9,netssh.c:
 
 5, 10, 3; 10,10
       10, 20; 10,pubkey.c:
@@ -66,9 +66,9 @@ percent of file involved, #lines in file involved; file2,filename2
       2, 15; 5,dh.c:
       2, 9; 6,dial.c:
 
-30, 257, 33; 6,7
-      59, 252; 6,dial.c:
-      57, 244; 7,dial.thread.c:
+33, 281, 33; 6,7
+      64, 275; 6,dial.c:
+      62, 267; 7,dial.thread.c:
 
 0, 10, 3; 8,9
       40, 6; 8,esmprint.c:
@@ -98,9 +98,9 @@ percent of file involved, #lines in file involved; file2,filename2
       25, 20; 1,cipheraes.c:
       51, 20; 3,cipherrc4.c:
 
-0, 3, 1; 5,7
-      0, 3; 5,dh.c:
-      1, 3; 7,dial.thread.c:
+1, 7, 2; 5,7
+      1, 7; 5,dh.c:
+      2, 7; 7,dial.thread.c:
 
 0, 15, 6; 7,9
       3, 13; 7,dial.thread.c:

+ 13 - 12
sys/src/cmd/ssh2/long.funcs

@@ -15,17 +15,17 @@
 94	dh.c:821,915	genkeys()
 93	netssh.c:3126,3219	shutdown()
 88	netssh.c:1418,1506	stclunk()
-85	dial.c:334,419	csdial()
-84	dial.thread.c:337,421	csdial()
+85	dial.c:338,423	csdial()
+84	dial.thread.c:343,427	csdial()
 82	netssh.c:1547,1629	alloc_conn()
 81	netssh.c:405,486	stlisconn()
 79	netssh.c:2694,2773	validatekexc()
-76	dial.c:423,499	call()
+76	dial.c:427,503	call()
 75	netssh.c:3008,3083	client_auth()
 74	netssh.c:997,1071	userauth()
 71	netssh.c:490,561	stlischan()
 70	netssh.c:2934,3004	auth_req()
-70	dial.thread.c:426,496	call()
+70	dial.thread.c:432,502	call()
 65	dh.c:315,380	rsa_verify()
 65	sshsession.c:338,403	newchannel()
 65	netssh.c:1633,1698	alloc_chan()
@@ -48,32 +48,33 @@
 40	ssh.c:204,244	cmdmode()
 38	dh.c:589,627	findkeyinuserring()
 38	dh.c:400,438	dss_sign()
+36	dial.thread.c:243,279	recvresults()
 35	dial.thread.c:93,128	dialimpl()
-35	ssh.c:248,283	keyprompt()
 35	dial.c:77,112	dialimpl()
+35	ssh.c:248,283	keyprompt()
 34	netssh.c:1374,1408	writedataproc()
 34	netssh.c:3088,3122	factlookup()
 33	netssh.c:278,311	server()
 32	transport.c:182,214	undo_packet()
 32	netssh.c:2827,2859	keyfsauth()
-32	dial.thread.c:243,275	recvresults()
 31	netssh.c:1781,1812	exchids()
-30	dial.thread.c:284,314	dialmulti()
+30	dial.thread.c:288,318	dialmulti()
+30	dial.c:304,334	dialmulti()
 30	ssh.c:587,617	doauth()
-30	dial.c:300,330	dialmulti()
 30	netssh.c:2790,2820	mkcap()
 30	ssh.c:86,116	parseargs()
 29	dial.thread.c:199,228	callproc()
-28	dial.c:528,556	_dial_string_parse()
-28	dial.thread.c:525,553	_dial_string_parse()
-27	netssh.c:1876,1903	dohandshake()
+28	dial.c:532,560	_dial_string_parse()
+28	dial.thread.c:531,559	_dial_string_parse()
 27	sshsession.c:96,123	mounttunnel()
 27	netssh.c:240,267	read9pmsg()
 27	netssh.c:1845,1872	deferredinit()
 27	cipherblowfish.c:16,43	initblowfish()
+27	netssh.c:1876,1903	dohandshake()
 26	sshsession.c:157,183	listenloop()
-26	ssh.c:446,472	remotecmd()
 26	sshsession.c:127,153	authnewns()
 26	pubkey.c:112,138	findkey()
+26	ssh.c:446,472	remotecmd()
+25	dial.c:169,194	notedeath()
 25	sshsession.c:420,445	confine()
 25	ssh.c:175,200	starttunnel()

+ 4 - 4
sys/src/cmd/ssh2/magic.out

@@ -76,16 +76,16 @@ dial.c:17: Maxcsreply	= 64*80,	/* this is probably overly generous */
 dial.c:22: Maxconnms	= 2*60*1000,	/* 2 minutes */
 dial.c:171: char *fields[5];			/* pid + 3 times + error */
 dial.c:177: if (n < 4)
-dial.c:188: strncpy(conn->err, fields[4], sizeof conn->err);
-dial.c:209: char exitsts[2*ERRMAX];
-dial.c:381: bleft = sizeof dp->addrlist - 2;	/* 2 is room for \n\0 */
+dial.c:188: strncpy(conn->err, fields[4], sizeof conn->err - 1);
+dial.c:210: char exitsts[2*ERRMAX];
+dial.c:385: bleft = sizeof dp->addrlist - 2;	/* 2 is room for \n\0 */
 dial.thread.c:22: Defstksize	= 8192,
 dial.thread.c:24: Maxstring	= 128,
 dial.thread.c:25: Maxpath		= 256,
 dial.thread.c:27: Maxcsreply	= 64*80,	/* this is probably overly generous */
 dial.thread.c:32: Maxconnms	= 2*60*1000,	/* 2 minutes */
 dial.thread.c:57: int	kidthrids[64];		/* one per addr; ought to be enough */
-dial.thread.c:387: bleft = sizeof dp->addrlist - 2;	/* 2 is room for \n\0 */
+dial.thread.c:393: bleft = sizeof dp->addrlist - 2;	/* 2 is room for \n\0 */
 netssh.c:48: PKA *pkas[3];
 netssh.c:71: char uid[32];
 netssh.c:175: case '9':

+ 8 - 4
sys/src/libc/9sys/dial.c

@@ -45,7 +45,7 @@ struct Conn {
 
 	int	dfd;
 	int	cfd;
-	char	dir[NETPATHLEN];
+	char	dir[NETPATHLEN+1];
 	char	err[ERRMAX];
 };
 struct Dest {
@@ -184,7 +184,8 @@ notedeath(Dest *dp, char *exitsts)
 				closeopenfd(&conn->dfd);
 				closeopenfd(&conn->cfd);
 			}
-			strncpy(conn->err, fields[4], sizeof conn->err);
+			strncpy(conn->err, fields[4], sizeof conn->err - 1);
+			conn->err[sizeof conn->err - 1] = '\0';
 			conn->dead = 1;
 			return;
 		}
@@ -224,8 +225,10 @@ fillinds(DS *ds, Dest *dp)
 	conn = &dp->conn[dp->winner];
 	if (ds->cfdp)
 		*ds->cfdp = conn->cfd;
-	if (ds->dir)
+	if (ds->dir) {
 		strncpy(ds->dir, conn->dir, NETPATHLEN);
+		ds->dir[NETPATHLEN] = '\0';
+	}
 	return conn->dfd;
 }
 
@@ -249,7 +252,8 @@ connectwait(Dest *dp, char *besterr)
 	for (conn = dp->conn; conn < dp->connend; conn++)
 		if (conn - dp->conn != dp->winner && conn->dead &&
 		    conn->err[0]) {
-			strncpy(besterr, conn->err, ERRMAX);
+			strncpy(besterr, conn->err, ERRMAX-1);
+			conn->err[ERRMAX-1] = '\0';
 			break;
 		}
 	return dp->winner;

Some files were not shown because too many files changed in this diff