Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!pasteur!agate!ucbvax!PURDUE.EDU!sdo From: sdo@PURDUE.EDU (Shawn Ostermann) Newsgroups: comp.os.xinu Subject: Old Bug uncovered Message-ID: <8902080440.AA16718@medusa.cs.purdue.edu> Date: 8 Feb 89 04:40:32 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 68 (A little trivia for pointer buffs) I was helping the VM Xinu guys track down a bug, and found a coding mistake that has been living in a library file for years. The bug is in the library file src/lib/libxc/doscan.c, and the interesting parts are as follows (watch the variable fileended): MANY LINES DELETED /* doscan.c - doscan */ ... _doscan( ... ) { int **ptr, fileended, size; ... fileended = 0; ... if (_innum(ptr, ch, len, size, getch, ungetch, arg1, arg2, fileended) && ptr) ... } ... _innum(ptr, type, len, size, getch, ungetch, arg1, arg2, eofptr) ... int *eofptr; { ... if (c != EOF) { (*ungetch)(arg1, arg2); *eofptr = 0; } else *eofptr = 1; ... } _innum is trying to use eofptr as a flag for doscan. The mistake (as you've ALL already seen (-: ) is that the call to innum SHOULD be if (_innum(ptr, ch, len, size, getch, ungetch, arg1, arg2, &fileended) && ptr) ^ to pass the ADDRESS of fileended, rather than a null pointer. The bug was never noticed in the old Xinu stuff because address 0 was writable, and not used. In VM Xinu, however, that is an illegal address for some processes, and the dereferencing causes a page fault (that's how I found it). A little poking around found that this routine has been included faithfully in all of the architecture distributions that I looked at. This will probably never affect anyone using the old Xinu stuff, but if you're a stickler for good pointer grammar, you might want to fix it. The moral of the story: Boy I'm glad that this module was written before I started working on the Xinu project, that way (for once) it's not my fault!!! (no pun intended) Anybody out there in Xinu land wanna own up to it????!!! Shawn ----------------------------------------------------------------------------- Shawn Ostermann ARPA: sdo@cs.purdue.edu UUCP: ...!purdue!sdo -----------------------------------------------------------------------------