code: drawterm

Download patch

ref: b86ca0bf8a11e9f03aa0a6af915285ef2bf80bd3
parent: b9347940d8f079bbf9f5301dc85a2223bdbaea6e
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Thu Apr 14 21:52:34 EDT 2016

fix error print in p9any negotiation (thanks Kenji Arisawa)

in drawterm/cpu.c, we have
		if(readstr(fd, buf, sizeof buf) < 0)
			fatal(1, "cannot read OK in p9any: got %d %s", n, buf);
perhaps this is intended to be
		if((n = readstr(fd, buf, sizeof buf)) < 0)
			fatal(1, "cannot read OK in p9any: got %d %s", n, buf);
but the latter is no help. readstr() returns 0 or -1, and if -1 the buf is not terminated by ‘\0’.
therefore these should be simply
		if(readstr(fd, buf, sizeof buf) < 0)
			fatal(1, "cannot read OK in p9any”);

by the way, how can I debug drawterm.
fprint(2,…) is no effect.

Kenji Arisawa

--- a/cpu.c
+++ b/cpu.c
@@ -673,9 +673,9 @@
 		fatal(1, "cannot write user/domain choice in p9any");
 	if(v2){
 		if(readstr(fd, buf, sizeof buf) < 0)
-			fatal(1, "cannot read OK in p9any: got %d %s", n, buf);
+			fatal(1, "cannot read OK in p9any");
 		if(memcmp(buf, "OK\0", 3) != 0)
-			fatal(1, "did not get OK in p9any");
+			fatal(1, "did not get OK in p9any: got %s", buf);
 	}
 	genrandom(crand, 2*NONCELEN);
 	genrandom(cchal, CHALLEN);