Commit Graph

23 Commits

Author SHA1 Message Date
Xi Wang
8a2a5b8f25 libsec: avoid undefined C
gcc compiles `p + length < p' into 'length < 0' since pointer overflow is undefined behavior in C.  This breaks the check against a large `length'.

Use `length > pend - p' instead.

There's no need to check `length < 0' since `length' is from length_decode() and should be non-negative.

===

Try the simplified code.

void bar(void);
void foo(unsigned char *p, int length)
{
        if (p + length < p)
                bar();
}

$ gcc -S -o - t.c -O2
...
foo:
.LFB0:
        .cfi_startproc
        testl	%esi, %esi
        js	.L4
        rep
        ret
.L4:
        jmp	bar
        .cfi_endproc

Clearly `p' is not used at all.

R=rsc
CC=plan9port.codebot
https://codereview.appspot.com/7231069
2013-03-19 14:35:16 -04:00
Russ Cox
0cfb376070 fix clang warnings reported by Tuncer Ayaz
R=rsc
http://codereview.appspot.com/6744054
2012-10-21 11:25:08 -04:00
Russ Cox
c38ef9e7b6 libsec: fix dsagen 64-bit bug 2011-10-05 16:23:01 -04:00
Russ Cox
1619f52cbc probably_prime: run more than one Miller-Rabin round
R=rsc
http://codereview.appspot.com/462041
2010-03-11 18:04:42 -08:00
Russ Cox
a1afc8529d libsec: update primetest to use mpfmt
R=rsc
http://codereview.appspot.com/464041
2010-03-11 18:04:12 -08:00
Russ Cox
350f4d3ede libsec: use intptr to silence 64-bit warning (Michael Teichgräber) 2008-03-06 15:14:03 -05:00
rsc
cbeb0b26e4 Use gcc -ansi -pedantic in 9c. Fix many non-C89-isms. 2006-04-01 19:24:03 +00:00
rsc
74fc94d47e add dsa x509 2005-02-13 18:35:11 +00:00
rsc
2709e6e368 new allocrpc interface 2005-02-11 16:44:33 +00:00
rsc
22c7ebffda more little compile fixes 2004-12-28 01:45:05 +00:00
rsc
73bfbacb24 silence various warnings 2004-12-27 19:13:31 +00:00
rsc
52e73e955b add portdate 2004-12-26 23:59:30 +00:00
rsc
1b1434ebce changes from plan 9. some clean-up. 2004-12-26 23:59:10 +00:00
wkj
7025271a71 Libsec doesn't compile without a reduce script, either. 2004-04-21 17:52:08 +00:00
rsc
6b17c8f11b more tomfoolery.
i bet mk can't read the mac os or sun os archives.
2004-04-21 06:53:59 +00:00
rsc
7ac9b0e140 make scripts work with more shells,
use current variable names.
2004-04-21 05:49:52 +00:00
rsc
1b135a7805 clean up when finished.
don't set PLAN9
don't set PLAN9
2004-04-19 23:04:36 +00:00
rsc
be22ae2d07 SunOS can rot in hell. 2004-03-26 01:59:35 +00:00
rsc
0fc65b37a1 Add most of libsec. 2004-03-21 14:04:56 +00:00
rsc
2277c5d7bb Small tweaks
Lots of new code imported.
2004-03-21 04:33:13 +00:00
rsc
64bcfff3a1 More tweaks on Linux and Solaris. 2003-11-25 02:11:11 +00:00
rsc
478ee9636f Make things build on FreeBSD again. 2003-11-23 20:04:53 +00:00
rsc
db6608bd81 add libsec 2003-11-23 18:21:42 +00:00