[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] Super() calls fixes



Hm, what about attaching the patch itself :)

On Mon, Sep 29, 2008 at 12:38 AM, Miro Kropacek <miro.kropacek@gmail.com> wrote:
Hi,

in case someone is interested (it seems my previous patches aren't still included), there's patch to mintlib when the code is in supervisor mode and it calls for example Getcookie() -- this function another one which calls Super() under TOS without any check for supervisor presence which leads to crash. I fixed this situation with all Super() calls I found. Plus some cosmetic changes. (I'm not sure about that (short) return values -- in compendium it as WORD but in TOS.HYP it's int32_t... I don't know the backround so if it's bad, just cut this part of patch away :)

--
MiKRO / Mystic Bytes
http://mikro.atari.org



--
MiKRO / Mystic Bytes
http://mikro.atari.org
Index: include/mint/osbind.h
===================================================================
RCS file: /mint/mintlib/include/mint/osbind.h,v
retrieving revision 1.7
diff -u -r1.7 osbind.h
--- include/mint/osbind.h	6 Dec 2005 19:27:55 -0000	1.7
+++ include/mint/osbind.h	28 Sep 2008 22:24:33 -0000
@@ -936,11 +936,11 @@
 #define	       Cconout(c)					       \
        (void)trap_1_ww((short)(0x02),(short)(c))
 #define	       Cauxin()						       \
-       (long)trap_1_w((short)(0x03))
+       (short)trap_1_w((short)(0x03))
 #define	       Cauxout(c)					       \
        (void)trap_1_ww((short)(0x04),(short)(c))
 #define	       Cprnout(c)					       \
-       (void)trap_1_ww((short)(0x05),(short)(c))
+       (short)trap_1_ww((short)(0x05),(short)(c))
 #define	       Crawio(data)					       \
        (long)trap_1_ww((short)(0x06),(short)(data))
 #define	       Crawcin()					       \
@@ -948,7 +948,7 @@
 #define	       Cnecin()						       \
        (long)trap_1_w((short)(0x08))
 #define	       Cconws(s)					       \
-       (void)trap_1_wl((short)(0x09),(long)(s))
+       (short)trap_1_wl((short)(0x09),(long)(s))
 #define	       Cconrs(buf)					       \
        (void)trap_1_wl((short)(0x0A),(long)(buf))
 #define	       Cconis()						       \
Index: include/mint/ostruct.h
===================================================================
RCS file: /mint/mintlib/include/mint/ostruct.h,v
retrieving revision 1.7
diff -u -r1.7 ostruct.h
--- include/mint/ostruct.h	22 Jan 2008 09:36:54 -0000	1.7
+++ include/mint/ostruct.h	28 Sep 2008 22:24:33 -0000
@@ -65,9 +65,11 @@
 #define DEV_READY		-1
 #define DEV_BUSY		0
 
-/* Super() modes */
-#define SUP_SET			(void*)0
-#define SUP_INQUIRE		(void*)1
+/* Super() constants */
+#define SUP_SET			0L
+#define SUP_INQUIRE		1L
+#define SUP_USER		0L
+#define SUP_SUPER		-1L
 
 /* Fopen() modes */
 #define S_READ			0x00
Index: mintlib/sysvar.c
===================================================================
RCS file: /mint/mintlib/mintlib/sysvar.c,v
retrieving revision 1.2
diff -u -r1.2 sysvar.c
--- mintlib/sysvar.c	23 Jul 2001 09:41:57 -0000	1.2
+++ mintlib/sysvar.c	28 Sep 2008 22:24:35 -0000
@@ -10,18 +10,21 @@
 get_sysvar (void *var)
 {
 	if(__has_no_ssystem) {
-		long save_ssp;
 		long ret;
-
-    		save_ssp = (long) Super((void *) 0L);
+		
+		if (Super(1L) == 0L) {
+			long save_ssp = (long) Super((void *) 0L);
 
 		/* note: dont remove volatile, otherwise gcc will reorder these
 		 * statements and we get bombs */
     		ret = *((volatile long *)var);
 
     		(void)Super((void *) save_ssp);
+    	} else {
+    		ret = *((volatile long *)var);
+    	}
 
-    		return ret;
+    	return ret;
 	}
 	else
 		return Ssystem (S_GETLVAL, var, NULL);
Index: unix/ioctl.c
===================================================================
RCS file: /mint/mintlib/unix/ioctl.c,v
retrieving revision 1.13
diff -u -r1.13 ioctl.c
--- unix/ioctl.c	1 Mar 2005 23:25:14 -0000	1.13
+++ unix/ioctl.c	28 Sep 2008 22:24:39 -0000
@@ -212,9 +212,13 @@
                   *msig |= ((g & (1 << 4)) ? 0 : TIOCM_DTR);
                   mfp = ((short *) 0xfffffa00L);
 		  if (__has_no_ssystem) {
-                  	ssp = Super(0L);
-                  	m = *mfp & 0xff;
+		  		if (Super(1L) == 0L) {
+		  			ssp = Super(0L);
+                	m = *mfp & 0xff;
                   	Super(ssp);
+                } else {
+                	m = *mfp & 0xff;
+                }
 		  } else
 		  	m = (short)(Ssystem(S_TIOCMGET, (u_long)mfp, NULL));
                   *msig |= ((m & (1 << 1)) ? 0 : TIOCM_CAR);
Index: unix/sysinfo.c
===================================================================
RCS file: /mint/mintlib/unix/sysinfo.c,v
retrieving revision 1.8
diff -u -r1.8 sysinfo.c
--- unix/sysinfo.c	15 Jun 2008 09:03:11 -0000	1.8
+++ unix/sysinfo.c	28 Sep 2008 22:24:39 -0000
@@ -297,10 +297,18 @@
 
 		if (Ssystem(-1, NULL, NULL))
 		{
-			save_stk = (void *) Super (NULL);
-			sysbase = *((long int**) 0x000004f2);
-			tosversion = *sysbase;
-			(void) Super ((void*) save_stk);
+			if (Super(1L) == 0L)
+			{
+				save_stk = (void *) Super (0L);
+				sysbase = *((long int**) 0x000004f2);
+				tosversion = *sysbase;
+				(void) Super ((void*) save_stk);
+			}
+			else
+			{
+				sysbase = *((long int**) 0x000004f2);
+				tosversion = *sysbase;
+			}
 		}
 		else
 		{