git: drawterm

Download patch

ref: e551ef409ae2b004595f38323ce212ed152f6c3f
parent: d13582b16550a18a1078dbfd2b2b501f579d4a66
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Nov 23 12:24:29 EST 2025

libdraw: fix integer overflow in icossin2() (thanks sleepydog)

--- a/libdraw/icossin2.c
+++ b/libdraw/icossin2.c
@@ -227,6 +227,7 @@
 {
 	int sinsign, cossign, tan, tan10, rem;
 	short *stp, *ctp;
+	uint ux, uy;
 
 	if(x == 0){
 		if(y >= 0)
@@ -238,19 +239,23 @@
 	sinsign = cossign = 1;
 	if(x < 0){
 		cossign = -1;
-		x = -x;
+		ux = -x;
+	} else {
+		ux = x;
 	}
 	if(y < 0){
 		sinsign = -1;
-		y = -y;
+		uy = -y;
+	} else {
+		uy = y;
 	}
-	if(y > x){
-		tan = 1000*x/y;
+	if(uy > ux){
+		tan = 1000*(uvlong)ux/uy;
 		tan10 = tan/10;
 		stp = &cosinus[tan10];
 		ctp = &sinus[tan10];
 	}else{
-		tan = 1000*y/x;
+		tan = 1000*(uvlong)uy/ux;
 		tan10 = tan/10;
 		stp = &sinus[tan10];
 		ctp = &cosinus[tan10];
--