9front - general discussion about 9front
 help / color / mirror / Atom feed
* libmemdraw memarc bug
@ 2019-03-07 10:23 Nick Owens
  0 siblings, 0 replies; only message in thread
From: Nick Owens @ 2019-03-07 10:23 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: Type: text/plain, Size: 319 bytes --]

in memarc there is no bound check for a large negative phi, which ends
up causing out of bounds memory access.

this can crash the system running devdraw if you call fillarc, etc,
with a large negative phi (0x8000000 will do).

attached is what i came up with for a fix, but maybe someone has a better idea.

thoughts?

[-- Attachment #2: arc.patch --]
[-- Type: text/x-patch, Size: 322 bytes --]

diff -r 3858597b72d7 sys/src/libmemdraw/arc.c
--- a/sys/src/libmemdraw/arc.c	Thu Mar 07 01:25:11 2019 +0100
+++ b/sys/src/libmemdraw/arc.c	Thu Mar 07 02:13:06 2019 -0800
@@ -56,6 +56,8 @@
 		beta = tmp;
 		phi = -phi;
 	}
+	if(phi < 0)
+		phi = 0;
 	if(phi >= 360){
 		memellipse(dst, c, a, b, t, src, sp, op);
 		return;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-03-07 16:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-07 10:23 libmemdraw memarc bug Nick Owens

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).