| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Big Problem |
-=> Quoting Luke Spry to All <=- LS> I'm having a big problem with a routine I've written. This routine LS> reads a text file into memory, One line at a time. This routine works LS> fine for most files but with some files the computer just goes LS> haywire. (One time, the CMOS was erased, The printer printed, The LS> modem clicked, and the floppy disk drive lights turned on !!!). The symptoms you describe are consistent with an unallocated pointer or buffer overflow. LS> #define BUFLEN 500 LS> #define MAXLINES 13000 LS> char* text[MAXLINES]; LS> char buffer[BUFLEN]; You have a buffer on the stack, but never check for overflow! This kind of thing is good at crashing return addresses. LS> /* read character from file into buffer until or EOF*/ actually until LS> LS> /* if it's a line feed ignore it */ ignore It would be easy to fix the code, but why not just open as "r" and use:- fgets(buffer, BUFLEN, textFile) --- Blue Wave/Max v2.20 [NR]* Origin: Sydney PC Users Group Mail Exchange (3:712/505) SEEN-BY: 50/99 620/243 623/630 711/401 409 410 413 430 510 807 808 809 932 SEEN-BY: 711/934 712/218 401 404 407 411 416 505 506 515 517 616 619 623 704 SEEN-BY: 712/816 848 713/306 888 714/906 800/1 7877/2809 @PATH: 712/505 704 515 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.