🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #549

Re: ANSI C, hardware protection, out-of-bounds pointers

#549
From: Joseph S. D. Yao
Date: Fri, 08 Sep 1989 17:15
20 lines
1504 bytes
In article <10970@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes:
-In article <867@hadron.UUCP> jsdy@hadron.UUCP (Joseph S. D. Yao) writes:
->-	char *head=a-1;		/* Here! */
->This, too, is an out-of-bounds pointer, and is covered by the same
->rule.  Nothing says that an OOB ptr has to be positively offset.
-Sorry, Joe, but you're wrong.  Only the last+1 OOB pointer is legal,
-not the first-1.  I've seen this fail in practice (in AT&T's UNIX
-implementation of bsearch(), as I recall) when the array element
-was fairly large and first-1 happened to wrap around the address
-space.

Erk.  You're right.  On the other hand (since stacks don't HAVE to be
at the end of data space), an array could also abut the end of data
space, and thus last+1 becomes NULL.  Is there anything forbidding
that?

For that matter, is there anything IN THE STANDARD that says first-1 is
illegal?  (Besides the general fact that it's bad practice, of course.)

Joe Yao
Technical Details
Message-ID: <868@hadron.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!ginosko!aplcen!haven!decuac!hadron!jsdy
References: <427@maytag.waterloo.edu> <867@hadron.UUCP> <10970@smoke.BRL.MIL>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!ginosko!aplcen!haven!decuac!hadron!jsdy
From: jsdy@hadron.UUCP (Joseph S. D. Yao)
Newsgroups: comp.std.c
Subject: Re: ANSI C, hardware protection, out-of-bounds pointers
Keywords: ANSI C, hardware protection, out-of-bounds pointers
Message-ID: <868@hadron.UUCP>
Date: 8 Sep 89 17:15:23 GMT
References: <427@maytag.waterloo.edu> <867@hadron.UUCP> <10970@smoke.BRL.MIL>
Reply-To: jsdy@hadron.UUCP (Joseph S. D. Yao)
Organization: Hadron, Inc., Fairfax, VA
Lines: 20