Mail Archives: djgpp/1998/01/22/12:52:10
On Fri, 23 Jan 1998, Jamie Love wrote:
> remdefs sprites.set
> I get the djgpp.env file!!! instead of the correct sprites.set file.
[snip]
> if((length = fread(data, 1, length, inFile)) != -1)
> {
> printf("Error: unable to read %d bytes from %s", length, argv[1]);
> return 0;
> }
>
> printf("%s\n", data);
You are assuming that `fread' appends an extra `\0' (null) character to
the buffer after it reads the file. This is false. So when `printf'
looks for the trailing `\0', which %s format requires, it happily runs
beyond the end of data[] and prints what's left from the DJGPP.ENV
processing by the startup code.
- Raw text -