No description
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
|
||
|---|---|---|
| acid | ||
| bin | ||
| dict | ||
| dist | ||
| face | ||
| font | ||
| include | ||
| lib | ||
| log | ||
| lp | ||
| mac | ||
| man | ||
| ndb | ||
| news | ||
| plumb | ||
| postscript | ||
| proto | ||
| sky | ||
| src | ||
| tmac | ||
| troff | ||
| unix | ||
| .cvsignore | ||
| .hgignore | ||
| .hgtags | ||
| CHANGES | ||
| configure | ||
| CONTRIBUTORS | ||
| INSTALL | ||
| install.txt | ||
| LICENSE | ||
| Makefile | ||
| rcmain | ||
| README | ||
| TODO | ||
This is a port of many Plan 9 libraries and programs to Unix.
* Installation
To install, run ./INSTALL. It builds mk and then uses mk to
run the rest of the installation.
For more details, see install(1), at install.txt in this directory
and at http://swtch.com/plan9port/man/man1/install.html.
* Documentation
See http://swtch.com/plan9port/man/ for more documentation.
(Documentation is also in this tree, but you need to run
a successful install first. After that, "9 man 1 intro".)
Intro(1) contains a list of man pages that describe new features
or differences from Plan 9.
* Helping out
If you'd like to help out, great! The TODO file contains a small list.
If you port this code to other architectures, please share your changes
so others can benefit.
Please use diff -u or CVS (see below) to prepare patches.
* CVS
You can use CVS to keep your local copy up-to-date as we make
changes and fix bugs. See the cvs(1) man page here ("9 man cvs")
for details on using cvs.
* Contact
Russ Cox <rsc@swtch.com>