home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!fuug!demos!kiae!glas!demos!curie.ces.cwru.edu!glenn
- From: glenn@curie.ces.cwru.edu
- Newsgroups: comp.lang.c
- Date: 17 Jul 92 10:46 MDT
- Subject: Array bounds checking
- Sender: Notesfile to Usenet Gateway <notes@glas.apc.org>
- Message-ID: <GLENN.92Jul17104644@curie.ces.cw>
- Nf-ID: #N:GLENN.92Jul17104644@curie.ces.cw:1802369180:001:1316
- Nf-From: curie.ces.cwru.edu!glenn Jul 17 10:46:00 1992
- Lines: 51
-
-
-
- Hey there. I've inherited a pathetic piece of "software", chock full
- o' things like
-
- foo = (char *) malloc (strlen (bar));
- strcpy (foo, bar);
-
- I've got 4 or 5 malloc debugging systems, so most problems like the
- above are solved now, but I'm trying to figure out a way to check for
- things like this:
-
- void foo(void)
- {
- int local[5];
-
- local[5] = 3;
- }
-
- Sure, I can change these to something like this:
-
- void foo(void)
- {
- int *local;
-
- local = (int *) malloc (sizeof (int) * 5);
- local[5] = 3;
- free (local);
- }
-
- (which my picky malloc debuggers will point out to me.)
-
- But this sucks. When I'm not debugging, I'd really like that array of
- ints to be on the stack.
-
- Any suggestions about systems that might do something like this? I
- know about CodeCenter (formerly Saber) C, which will do this in its
- sleep, but it's quite costly, and I'd like to either find or write
- something GNUish.
-
- If there's nothing out there, I'd appreciate suggestions on how best
- to do this. What I'm thinking about currently is an option to GCC
- like -fruntime-bounds-check. If anyone's given this some thought, I'd
- love to hear about it.
-
- --
- Glenn Crocker | Hackers aren't unethical, they're
- glenn@ces.cwru.edu | "Differently-ethical."
- CWRU, Cleveland, OH |
- W (216)368-6133 H (216)791-4610 |
-
-