So I guess this is one sort of "anything"! I could inspect the generated code to see why, but I'd rather you just switched to using a safe function like fgets :-) I agree it's odd that stack smashing isn't detected when you reduce the array size to 2 but I always tell my students that once you corrupt the stack, anything may happen. I'd suggest using fgets to read strings, rather than scanf. The compiler could be secretly passing some additional information to the scanf function, or setting up some guard value at the end of all arrays to detect the overflow, but I can't see any reference on the web to such a capability. I'm surprised that xcode is apparently able to detect that buffer overflow. The scanf function is passed just a pointer to the destination address and (usually, anyway) has no way of knowing how much space is available. Using scanf with a %s format is inherently unsafe. I get exactly the same results as you running your program within the geany mini-IDE. What you're seeing there is standard GNU C behaviour, at least under Linux. var/But even more suprisingly if you enter 2 instead of MAX_LAENGE there is no error message at all. *** stack smashing detected ***: ./prog.c.exe terminated If you reduce the size of the arrays manually, it starts complaining when entering 8 instead of MAX_LAENGE : Xcode gives me those error messages as soon as the arrays are smaller then 12 for Raumschiff1 and Raumschiff2īut Coderunner won't moan and would give you a "2" as a result (which is my definition of Raumschiff1 and Raumschiff2 are not the same signs). If(chrEingabe1!=chrEingabe2) intReturnWert = 2 Įntering this in a normal IDE it should spit out an error, cause Raumschiff1 and Raumschiff2 are both 11signs long. While((intCounter
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |