Browse Source

Plan 9 from Bell Labs 2013-08-16

David du Colombier 5 years ago
parent
commit
65aa140a9d
4 changed files with 22 additions and 8 deletions
  1. 1 1
      sys/man/6/style
  2. 1 1
      sys/src/9/port/cache.c
  3. 19 5
      sys/src/cmd/ndb/convM2DNS.c
  4. 1 1
      sys/src/libmach/executable.c

+ 1 - 1
sys/man/6/style

@@ -4,7 +4,7 @@ style \- Plan 9 coding conventions for C
 .SH DESCRIPTION
 Plan 9 C code has its own conventions.
 You would do well to follow them.
-Here are a few:
+Here are a few (and this is not an exhaustive list):
 .IP • 3
 don't use
 .L //

+ 1 - 1
sys/src/9/port/cache.c

@@ -114,7 +114,7 @@ cinit(void)
 
 	/* a better algorithm would be nice */
 	if(conf.npage*BY2PG > 400*MB)
-		maxcache = 50*MAXCACHE;
+		maxcache = 20*MAXCACHE;
 	else if(conf.npage*BY2PG > 200*MB)
 		maxcache = 10*MAXCACHE;
 

+ 19 - 5
sys/src/cmd/ndb/convM2DNS.c

@@ -41,13 +41,19 @@ errtoolong(RR *rp, Scan *sp, int remain, int need, char *where)
 			rrname(rp->type, ptype, sizeof ptype));
 	p = seprint(p, ep, "%d bytes needed; %d remain", need, remain);
 	if (rp)
-		seprint(p, ep, ": %R", rp);
-	sp->err = sp->errbuf;
-	/* hack to cope with servers that don't set Ftrunc when they should */
-	if (remain < Maxudp && need > Maxudp)
+		p = seprint(p, ep, ": %R", rp);
+	/*
+	 * hack to cope with servers that don't set Ftrunc when they should:
+	 * if the (udp) packet is full-sized, if must be truncated because
+	 * it is incomplete.  otherwise, it's just garbled.
+	 */
+	if (sp->ep - sp->base >= Maxudp) {
 		sp->trunc = 1;
+		seprint(p, ep, " (truncated)");
+	}
 	if (debug && rp)
 		dnslog("malformed rr: %R", rp);
+	sp->err = sp->errbuf;
 	return 0;
 }
 
@@ -328,6 +334,7 @@ static RR*
 convM2RR(Scan *sp, char *what)
 {
 	int type, class, len, left;
+	char *dn;
 	char dname[Domlen+1];
 	uchar *data;
 	RR *rp;
@@ -396,7 +403,12 @@ retry:
 		break;
 	case Tmx:
 		USHORT(rp->pref);
-		rp->host = dnlookup(NAME(dname), Cin, 1);
+		dn = NAME(dname);
+		rp->host = dnlookup(dn, Cin, 1);
+		if(strchr((char *)rp->host, '\n') != nil) {
+			dnslog("newline in mx text for %s", dn);
+			sp->trunc = 1;		/* try again via tcp */
+		}
 		break;
 	case Ta:
 		V4ADDR(rp->ip);
@@ -555,6 +567,8 @@ rrloop(Scan *sp, char *what, int count, int quest)
  *  if there are formatting errors or the like during parsing of the message,
  *  set *codep to the outgoing response code (e.g., Rformat), which will
  *  abort processing and reply immediately with the outgoing response code.
+ *
+ *  ideally would note if len == Maxudp && query was via UDP, for errtoolong.
  */
 char*
 convM2DNS(uchar *buf, int len, DNSmsg *m, int *codep)

+ 1 - 1
sys/src/libmach/executable.c

@@ -844,7 +844,7 @@ elfdotout(int fd, Fhdr *fp, ExecHdr *hp)
 	else if(ep->ident[CLASS] == ELFCLASS64)
 		return elf64dotout(fd, fp, hp);
 
-	werrstr("bad ELF class - not 32 bit");
+	werrstr("bad ELF class - not 32- nor 64-bit");
 	return 0;
 }