shithub: riscv

Download patch

ref: ee31c7808087c24b268bb5700b6d695c1bae0cd8
parent: e0d2453f56ac602e3d70e55cb2ff06a39f6ca20a
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Oct 17 19:35:37 EDT 2021

libsec: fix operator precedence bugs (thanks kemal)

--- a/sys/src/libsec/port/tlshand.c
+++ b/sys/src/libsec/port/tlshand.c
@@ -660,7 +660,7 @@
 			goto Short;
 		switch(get16(p-4)){
 		case Extec:
-			if(n < 4 || n & 1 || get16(p) != (n -= 2))
+			if(n < 4 || n % 2 || get16(p) != (n -= 2))
 				goto Short;
 			p += 2;
 			for(i = 0; i < nelem(namedcurves) && c->sec->nc == nil; i++)
@@ -1574,7 +1574,7 @@
 		nn = get16(p);
 		p += 2, n -= 2;
 
-		if((nn & 1) || n < nn || nn < 2)
+		if(nn % 2 || n < nn || nn < 2)
 			goto Short;
 		m->u.clientHello.ciphers = newints(nn >> 1);
 		for(i = 0; i < nn; i += 2)
@@ -1663,7 +1663,7 @@
 				goto Short;
 			nn = get16(p);
 			p += 2, n -= 2;
-			if(nn & 1)
+			if(nn % 2)
 				goto Short;
 			m->u.certificateRequest.sigalgs = newints(nn>>1);
 			for(i = 0; i < nn; i += 2)