tech-userlevel archive

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

__ssp_overlap() bug?



Hi

I think the recently added __ssp_overlap() macro is incorrect, as adjacent 
areas will trigger it. example test code below shows the problem..

#include <ssp/ssp.h>
#include <stdio.h>

int a, b;

int
main(int argc, char *argv[])
{

	printf("a %p, b %p, l %zu\n", &a, &b, sizeof(a));

	if (__ssp_overlap((char *)&a, (char *)&b, sizeof(a)))
		printf("a and b overlap\n");
	else
		printf("no overlap\n");

	return 0;
}

and patch to fix.. is this ok to commit?

iain

Index: ssp.h
===================================================================
RCS file: /cvsroot/src/include/ssp/ssp.h,v
retrieving revision 1.11
diff -u -p -r1.11 ssp.h
--- ssp.h	9 May 2015 15:41:47 -0000	1.11
+++ ssp.h	2 Sep 2015 20:15:56 -0000
@@ -78,7 +78,7 @@ __ssp_inline rtype fun args { \
     __ssp_redirect_raw(rtype, fun, fun, args, call, __ssp_bos0)
 
 #define __ssp_overlap(a, b, l) \
-    (((a) <= (b) && (b) <= (a) + (l)) || ((b) <= (a) && (a) <= (b) + (l)))
+    (((a) <= (b) && (b) < (a) + (l)) || ((b) <= (a) && (a) < (b) + (l)))
 
 __BEGIN_DECLS
 void __stack_chk_fail(void) __dead;


Home | Main Index | Thread Index | Old Index